我一直在寻找那些3:
主题,行为主体和重播主题.我想使用它们,知道何时以及为什么,使用它们有什么好处,虽然我已阅读文档,观看教程和搜索谷歌,但我没有对此有任何意义.
那他们的目的是什么?一个真实的案例将是非常感谢它甚至不必编码.
我更喜欢一个干净的解释,而不只是"a + b => c,你订阅了......"
谢谢
javascript reactive-programming rxjs angular2-observables angular
我有这个代码:
export class ProgramComponent implements OnInit {
@Input() events: Observable<any>;
eventsSubscription: any;
...
ngOnInit() {
this.eventsSubscription = this.events.subscribe((event) => {
... <- Some code that I want to test!!!!
console.log("The test doesn't get past here!!!!");
});
}
}
describe('BLA BLA BLA', () => {
let component: ProgramComponent;
let fixture: ComponentFixture<ProgramComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
...
],
declarations: [ProgramComponent],
providers: [
...
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ProgramComponent);
component = fixture.componentInstance;
// HERE I WANT TO …Run Code Online (Sandbox Code Playgroud)