Skip to content

Instantly share code, notes, and snippets.

@IniZio
Last active December 16, 2021 17:28
Show Gist options
  • Save IniZio/e085454fe52b95cfdd03c4089b79a434 to your computer and use it in GitHub Desktop.
Save IniZio/e085454fe52b95cfdd03c4089b79a434 to your computer and use it in GitHub Desktop.
Reim V4
function Counter() {
const { data: { count }, fire } = useReim(counter);
return (
<div>
<button onClick={() => fire(Increment)}>-</button>
<input value={count} />
<button onClick={() => fire(Decrement)}>-</button>
</div>
)
}
function LoginForm() {
const { refetch: { validateEmail }} = validateEmailQuery();
const loginForm = useReim(() => {
const email = data();
const password = data();
const NativeOnChange = event();
on(NativeOnChange, {
filter: { name: 'email' },
effect(event) {
validateEmail({ variables: { email: event.target.value });
}
});
});
return (
<form>
</form>
);
}
const count = data();
const Previewing = state();
const Editting = state();
const Increment = event();
const Reset = event();
on(Increment, {
condition: Previewing,
target: Editting,
effect: (payload) => (state) => {
return {
...state,
value: state.value + 1
}
}
});
on({
event: Reset,
condition: Previewing,
target: Editting,
effect: p((state) { // Using immer
state.value = 0
})
});
Reset.flow(
debounce(30),
({ delta }) => {
})
)
export default reim({ count })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment