This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://gist.github.com/dinony/60332358d25fd18d561395e0b8bf807c | |
// In the above Gist, we've discussed the constraints of unicast Observables, | |
// when it comes to sharing a costly resource. | |
// | |
// Here, you'll see how Subjects can be used to avoid this problematic scenario. | |
import {Obervable} from 'rxjs/Observable'; | |
import {Subject} from 'rxjs/Subject'; | |
// Again, we have our default Observable, which manages some costly resource. | |
const obs = new Observable(observer => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Here, we create a default Observable, which manages some costly resource | |
// or performs some heavy computation (denoted by the crying emoji) to push | |
// values to it's Observers. Now imagine, this could be a http call, | |
// database connection or socket connection, etc ... | |
// | |
// Each subscribed Observer gets an independent execution context. | |
// If we had only a single subscribe call - everything would be fine. | |
// We'd have just a single execution, and the costly resource is allocated | |
// just one time. So far, so good. | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from '@angular/core'; | |
import {myAnim} from './myAnim'; | |
@Component({ | |
selector: 'app-shell', | |
styles: [` | |
.container { | |
display: flex; | |
justify-content: center; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Component} from '@angular/core'; | |
import {trigger, state, style, animate, transition} from '@angular/animations'; | |
@Component({ | |
selector: 'my-comp', | |
styles: [], // <-- Add your styles here | |
animations: [], // <-- Add your animation meta data here | |
template: '' // <-- Define your template here | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {NgModule} from '@angular/core'; | |
import {BrowserModule} from '@angular/platform-browser'; | |
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; | |
import {AppComponent} from './app.component'; | |
@NgModule({ | |
bootstrap: [AppComponent], | |
declarations: [AppComponent], | |
imports: [BrowserModule, BrowserAnimationsModule] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
System.config({ | |
transpiler: 'ts', | |
meta: { | |
'typescript': { | |
"exports": "ts" | |
} | |
}, | |
paths: { | |
'npm:': 'https://unpkg.com/' | |
}, |