-
Notifications
You must be signed in to change notification settings - Fork 2
[question] use with other libraries #2
Comments
Composi shares some features externally with React because of the use of JSX. This provides JSX features such as |
Makes sense, thanks. A couple more thoughts that are likely going off-topic:
|
Well, technically lifecycle hooks are not events. That's why I call them hooks. The just look like events due to the React precedence. They are actually just JSX attributes that exist on the virtual nodes. They never become anything real in the real DOM. You mention "make more abstract API layers". I suppose you're talking about Composi? If so, the state management runtime is already quite agnostic. The render function just passes state to whatever you want to use to render it with. By default Composi uses its own render function, but you could use it for React, Vue, or whatever. Here is an example of Composi state management using React to render a function component that uses React hooks (useEffect): import React from 'react';
import { render } from './utils'
import { run } from '@composi/core'
import { List } from './components/list'
import { actions } from './effects/actions'
import { batchedSubscriptions } from './effects/subscriptions'
const program = {
init() {
return [null]
},
view(state, send) {
return state && render(<List {...{state, send}} />, 'section');
},
update(state, msg, send) {
return actions(state, msg, send)
},
subscriptions(state, send) {
return batchedSubscriptions
}
}
run(program) |
+1, wouldn't mind some more documentation on this
Is there an example somewhere? I would like to take a look at this kind of thing, may give it a try with React Native. |
OK, just uploaded this project: https://github.com/composi/list-react It was created with |
When this project first runs, a subscription launches that fetches initial data from a JSON file in the |
By the way, this project is basically the same as the full Composi project: https://github.com/composi/examples/tree/master/2-complex%20projects/4-todo-list. The Composi project has a total JavaScript payload of 23KB minified. This React version has a total JavaScript payload of 126KB minified. |
Thanks @rbiggs. I gave it a try yesterday, had some trouble porting to React Native since it seem to use very modular CSS. I hope to take another look, someday. |
As an update to this issue, I've created a version of @composi/core that is just the state manage, along with tagged unions and batched effects.It weighs in a about 600 kb. It's available from npm: npm I -D @composi/runtime Github repo: https://github.com/composi/runtime You can use React as the render, as in this repo: https://github.com/composi/list-react Documentation is the same as regular runtime of @composi/core: https://composi.github.io/en/docs/runtime/runtime.html |
such as:
and some native view frameworks from #3:
The text was updated successfully, but these errors were encountered: