Proposal to support event handlers #268
pastelmind
started this conversation in
Ideas
Replies: 1 comment 4 replies
-
React-RxJS is more suited for global state. We already have import { createSignal } from '@react-rxjs/utils';
const [observable$, handler] = createSignal();
// Compose observable$ to create other observables
const MyComponent = () => {
return <button onClick={handler}>
Click me
</button>
} Your proposal is quite close to the approach https://github.com/crimx/observable-hooks are using. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
React's basic data flow is, roughly:
Currently, react-rxjs only handles part B. This proposal discusses part A.
When using React and RxJS, there are two ways of handling events.
fromEvent
directly on DOM elements, working outside React's event systemNeither is clearly desirable. Instead, what if react-rxjs provided a helper that creates event handlers using RxJS operators?
Here is a tentative type signature for such a helper:
E.g.
(We could flesh out the details of
useHandler()
later)This would provide a better story for React devs who want to use RxJS (or vice versa).
Beta Was this translation helpful? Give feedback.
All reactions