mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
todos-preact
This commit is contained in:
20
docs/examples/todos-preact/app.js
Normal file
20
docs/examples/todos-preact/app.js
Normal 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)
|
||||
Reference in New Issue
Block a user