Coder Social home page Coder Social logo

Signal store and signal state should have something like connectSignal and connectObservable to connect streams/signals to state about platform HOT 2 CLOSED

sokolej79 avatar sokolej79 commented on June 6, 2024 3
Signal store and signal state should have something like connectSignal and connectObservable to connect streams/signals to state

from platform.

Comments (2)

rainerhahnekamp avatar rainerhahnekamp commented on June 6, 2024

That is actually a built-in feature of rxMethod:

    const Store = signalStore(
      withState({ date: new Date() }),
      withMethods((store) => ({
        updateTime: rxMethod<Date>(
          pipe(tap((date) => patchState(store, { date })))
        ),
      }))
    );

    const date$ = interval(1000).pipe(map(() => new Date()));
    const store = new Store();
    store.updateTime(date$);

    effect(() => {
      console.log(store.date());
    });

rxMethod would also be able to consume a signal instead of an Observable.

Was that what you were looking for?

from platform.

sokolej79 avatar sokolej79 commented on June 6, 2024

Thanks for the reply.
I know this way how to currently connect observable or signal with Store,
I thought that these helper methods like connectToStore similar to withMethods would be a more transparent way.
I see that there is not much interest, so I am closing.
Thanks anyway.

from platform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.