Created
May 28, 2016 16:22
-
-
Save xmlking/3d2030f28cfa3bee8a230312f1b9714b to your computer and use it in GitHub Desktop.
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
import { Http } from '@angular/http'; | |
import { Observable } from 'rxjs/Observable'; | |
import { Observer } from 'rxjs/Observer'; | |
import 'rxjs/add/operator/share'; | |
import { Todo } from 'app/interfaces'; | |
export class TodosService { | |
todos$: Observable<Todo[]>; | |
private _todosObserver: Observer<Todo[]>; | |
private _dataStore: { | |
todos: Todo[] | |
}; | |
constructor(private _http: Http) { | |
this._dataStore = { todos: [] }; | |
// Create Observable Stream to output our data | |
this.todos$ = new Observable(observer => this._todosObserver = observer).share(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment