Skip to content

Instantly share code, notes, and snippets.

View tomastrajan's full-sized avatar
🍰
Where is the cake?

Tomas Trajan tomastrajan

🍰
Where is the cake?
View GitHub Profile
@tomastrajan
tomastrajan / some.component.ts
Created October 20, 2022 21:38
Angular DX syntax proposal - more decorators 😅
@Component({ /* ... */ })
export class SomeComponent {
// streamifies input
@Input$() prop: Observable<string>;
// lifecycle notifier as an Observable stream
@OnDestroy$() destroy$: Obseravble<void>;
// lifecycle hook as decorator instead of implements interface
@erikringsmuth
erikringsmuth / JavaScript DI and Modules.md
Last active March 24, 2017 10:15
JavaScript DI and Modules

Here's a more in depth explanation of Angular's DI, RequireJS, and what's coming up in Angular 2.0 and ES6 modules.

Angular DI is not a module loader! It injects objects that have already been loaded using script tags. It does not do lazy-loading. Angular 2.0 will use ES6 import for module loading. Angular 2.0 will also add a DI layer that runs after the modules load.

I need to go over Java's import vs. JavaScript's require/import and Java singletons to further explain what Angular's DI is doing.

Java's import allows you to access another package's types without fully qualifying the package name. JavaScript's import loads a module and creates references to the module's exported objects. These are very different operations. JavaScript's import is powerful stuff! You have the objects, not just aliases to a package's types.

Singleton is a pattern, not the object itself. In Java you start with a type and have to create an instance. The singleton pattern ensures you have only 1 instance of that t