kosich / rxjs-proxify

Turns a Stream of Objects into an Object of Streams
MIT License
35 stars 3 forks source link

proxify(stream) with distinct values #10

Closed magne4000 closed 1 year ago

magne4000 commented 3 years ago

I have a readable Observable State, not created by statify, used with proxify, and I would like to have the ability to have a distinctUntilChanged on each property like statify does.

My use case is making a redux state Observable (readonly at first) through this lib.

kosich commented 3 years ago

Hey! A very interesting use-case, I'd love to hear more about your project.

Currently, the functionality you're asking for is present already but is not currently exported. Here's the core function, that is used by both proxify and statify and that has a distinct flag doing the trick https://github.com/kosich/rxjs-proxify/blob/master/src/core/proxy.ts#L7

And currently, you can import that function (in a hacky way):

import { coreProxy } from "rxjs-proxify/dist/cjs/core/proxy.js";

Here's a full example using that fn: https://stackblitz.com/edit/rxjs-proxify-distincted-proxify-example?file=index.ts

As I understand, you're working on a PoC. Please, give the example above a try, and if everything goes fine — I'll add the flag to the official API with the next release, so that you won't have to rely on the internals.

GL

magne4000 commented 3 years ago

Just tried it, it works exactly as I needed!