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

Ideas for Custom Operators #5

Open
johnlindquist opened this issue Apr 9, 2018 · 1 comment
Open

Ideas for Custom Operators #5

johnlindquist opened this issue Apr 9, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@johnlindquist
Copy link
Owner

I deprecated switchProps in favor of coming up with a custom operator approach, but I don't know what it is yet :)

I've also been toying with catchMap (to render a component when an error is thrown) and other ideas.

Any other ideas?

@johnlindquist johnlindquist added the enhancement New feature or request label Apr 9, 2018
@JaimeStill
Copy link

JaimeStill commented Oct 29, 2018

Looking at the Stream component, it should provide callbacks for both the err and complete functions. Usage would be something similar to the following:

handleError = (err) => this.setState((state) => ({ hasError: true, error: err }));
handleComplete = () => this.setState((state) => ({ isComplete: true }));

render = () => (
  <React.Fragment>
    <Stream source={source$}
            error={this.handleError}
            complete={this.handleComplete}>
      {x => <p>{x.val}</p>}
    </Stream>
    {this.state.hasError && <p>{this.state.error}</p>}
    {this.state.isComplete && <p>Stream Complete!</p>}
  </React.Fragment>
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants