reactive programming - RxJS Does Observable empty the data array after onCompleted is called? -


i struggling rxjs. questions observable

  1. does observable empty data array after oncompleted called?
  2. when chain 2 subscribe() method got error "subscribe not exist in type subscription". why that?

    someobs.map(...).subscribe(...).subscribe(...)

  3. is there way check observable data array count without subscribing?

  4. if observable clears data items after emitting them there way refill new data items same observable instance without creating new one? if yes, how?

  1. no. rxjs close cousin of functional programming, means mutation big no-no. whole point of streaming data avoid state mutation, in many ways source of many troubles in today's applications.

all observables wrap various data source types emit events through common interface. hence rx.observable.fromarray , rx.observable.frompromise both produce observables same semantics, difference being number of events , when events produced.

  1. observables lazy, fancy method chaining doesn't until observable subscribed to. subscribe saying "execute" or "go", allow events begin moving through observable.

  2. not sure mean "observable data array", see point 1. if pass array observable should able check size of that

  3. it doesn't, yes can in sense "refill" observable based on array resubscribing it, begin process of sending events again. dvlsg mentioned use subject explicitly push events observer, in 99% of cases use can , should avoided because being used crutch avoid having reactive

i.e.

var source = rx.observable.fromarray([1, 2, 3, 4]);  //first subscription, prints of events array source.subscribe(x => console.log(x));  //second subscription, prints events *again* because //this new subscription occurrence source.subscribe(y => console.log(y)); 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -