todos-preact

This commit is contained in:
Dmitry Vasilev
2023-06-19 07:59:21 +03:00
parent 1a93e5c493
commit c918674d0c
3 changed files with 165 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
import {render} from 'https://unpkg.com/preact?module';
let state, component, root
export const createApp = initial => {
/* if state is already initialized then preserve it */
state = state ?? initial.initialState
component = initial.component
root = initial.root
do_render()
}
export const handler = fn => (...args) => {
state = fn(state, ...args)
do_render()
}
export const connect = comp => props => comp(props, state)
const do_render = () => render(component(), root)