Last active
December 16, 2021 17:28
-
-
Save IniZio/e085454fe52b95cfdd03c4089b79a434 to your computer and use it in GitHub Desktop.
Reim V4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Counter() { | |
const { data: { count }, fire } = useReim(counter); | |
return ( | |
<div> | |
<button onClick={() => fire(Increment)}>-</button> | |
<input value={count} /> | |
<button onClick={() => fire(Decrement)}>-</button> | |
</div> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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