Skip to content

Feature request: useObservable to return the instant value on Component initialize if Observable has sync value #369

Open
@gyz0072004

Description

@gyz0072004

In my component, I use an useEffect to do some initialization with side effect.

const title = useObservable(() => titles$);
useEffect(() => {
    // do initialization with title
}, []);

title$ is a BehaviorSubject, so I would like the useEffect block can get the current title value directly, so that I don't need to wait another cycle for the initialization.

Activity

auver

auver commented on Sep 16, 2020

@auver

I also need it. The above code may solve your problem.
https://github.com/auver/rxjs-hooks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @auver@gyz0072004

        Issue actions

          Feature request: useObservable to return the instant value on Component initialize if Observable has sync value · Issue #369 · LeetCode-OpenSource/rxjs-hooks