bs-rx icon indicating copy to clipboard operation
bs-rx copied to clipboard

Support for subjects

Open hanrelan opened this issue 5 years ago • 2 comments

Does the library have any support for subjects? If not, any pointers on how to add that in?

Thanks!

hanrelan avatar Jan 07 '20 03:01 hanrelan

Just fyi, I did something like the following and it seems to work:

  [@bs.module "rxjs"] [@bs.new]
  external makeSubject: unit => subject('a) = "Subject";

  module Subject = {
    [@bs.send] external next: (subject('a), 'a) => unit = "next";
    [@bs.send] external error: (subject('a), 'e) => unit = "error";
    [@bs.send] external complete: subject('a) => unit = "complete";
    external observer: subject('a) => Rx.observer('a) = "%identity";
    external observable: subject('a) => Rx.observable('a) = "%identity";
  };

hanrelan avatar Jan 07 '20 03:01 hanrelan

Thank you @hanrelan for your inputs. The library does not currently support Subject. What you are attempting will work. I had imagined something similar. Subject would essentially be a tuple of (observer, observable). Functions like next, error and complete would be available on observer and observable would be ordinary observable.

mistyharsh avatar Jan 19 '20 12:01 mistyharsh