long time lurker - first time poster. This is a lot of theory, so bear with me.
I am working to mentally model the idea of an observable, observer and a subscriber (rxjs and angular2) and wanted to make sure I am on the right track.
I currently understand observables as "streams of events that can be watched and acted upon". arrays and requests can be cast as observable so that an observer can subscribe to them and when an event is fired can act on that event or the data in the observable.
I see that a subscriber is a type of observer that can watch an observable with 3 possible handlers: onNext, onComplete and onError.
I understand these can be in separate classes so long as the subscriber can gain access to the observable to subscribe.
Please let me know if this is an accurate description.
If this is true, I am curious as how to make an array observable as in: when new items are added to the array, how do I subscribe to that event and act upon it?
I have tried working through this by creating an array, filling it with mouse events and attempting to cast this array as Observable.
This failed, but I was able to create an observable subject, pushing new items in with next() and subscribing to those next events with a subscriber (which I have no idea what type it is, so I just left it untyped as I could not get the compiler to accept anything I put in).
my questions are:
1) Is my above understanding of observable & observer/subscriber correct?
2) can I create a standard array, make it observable and listen to 'added' or 'modified' events?
3) what is the type of the subscriber that I mention above?
this.mouseLocationSubscriber = this.mLocs$.subscribe(
X => this.handleNext(X),
err => this.handleSubscriberError(err),
() => console.log('subscriber recd complete')
);
Please:
if this post is in the wrong place, help me put it in the right spot
if this post is incorrectly formatted, help me understand how to format it for the best possibility of finding an answer
if this post is a dupe of some similar lost code theorist, help me find that response
if there is any thing else I should be mobbed for, I have prepared you a pitchfork: ----E