$chiubaca / notes / fleeting / 2021-03-28
  • Starting to learn the basics of RxJS and observables, a useful tool for working with async processes using a new primitive called oberservables.
  • in RxJS you set up a one time process called an epic which represents “pipes” of your async code. All async data flows through these pipes and our pipes can run actions to based on this data, it works well with asycn processes in redux. RxJS also comes with a bunch of ready to go methods to managing data, such as map, reduce and debounce so it can also be considered a utility lib like lodash but for async code.
  • the oberserbable primitive is not too dissimilar to a Promise. A Promise can resolve or reject. A Observable has three arguments.
    • A callback when the data stream was successful
    • A callback when the data stream was unsuccessful
    • A callback when the data stream has completed or ended
    // example oberservable
    myObservable.subscribe(
      (value) => console.log("next", value),
      (err) => console.error("error", err),
      () => console.info("complete!")
    );
Edit on GitHub ✏️

Hey I'm Alex Chiu 👋. These are my notes for literally anything.

I'm using the Zettelkasten method to organise my thoughts here.

My more polished writings are published to my main blog at chiubaca.com

Follow me on: Github / X (Twitter) / Mastodon / LinkedIn