Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rxjs): Correct useObservable type signature and provide means of creating a non-undefined Ref #1551

Merged
merged 2 commits into from May 3, 2022

Conversation

scvnc
Copy link
Contributor

@scvnc scvnc commented May 3, 2022

Description

Current behavior: useObservable has a return type signature of Ref<H> when in practice it returns Ref<H | undefined> because there exists a moment where the ref could contain undefined since the observable may not have emitted yet.

I'll also write docs if this solution looks decent to the maintainers.

Additional context

Please see #1544 and #1416 for more context.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

…lue config.

- By default useObservable<H> now has a return type Ref<H | undefined> as this is the correct type for how this composable behaves.
- To make useObservable<H> return Ref<H> you must provide an config.initialValue of type H

Related discussion vueuse#1416
@antfu antfu merged commit 5f3d026 into vueuse:main May 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Correct useObservable type signature and provide means of creating a non-undefined Ref
2 participants