Comments (4)
The example is a bit outdated, the output
method is renamed to use
, and we recommend using component
, instead of modelView
, since it has less boilerplate.
I'll make sure to update the documentation
Here is a more up-to-date example: https://codesandbox.io/s/vigorous-wood-qxv90?fontsize=14&hidenavigation=1&theme=dark
import { accum, combine } from "@funkia/hareactive";
import { runComponent, elements as E, component } from "@funkia/turbine";
const counter = component((on, start) => {
const increment = on.incrementClick.mapTo(1);
const decrement = on.decrementClick.mapTo(-1);
const changes = combine(increment, decrement);
const count = start(accum((n, m) => n + m, 0, changes));
return [
"Counter ",
count,
" ",
E.button("+").use({ incrementClick: "click" }),
" ",
E.button("-").use({ decrementClick: "click" })
];
});
runComponent("#mount", counter);
from turbine.
But with the component is there no way to test the model. I never write tests, but when I do, they involve chrome and selectors. I suppose that modelview is still an option.
from turbine.
yes, modelView
is still an option, the example would then be
import { accum, combine, instant } from "@funkia/hareactive";
import { runComponent, elements as E, modelView } from "@funkia/turbine";
const counterView = ({ count }) =>
E.div([
"Counter ",
count,
" ",
E.button("+").use({ incrementClick: "click" }),
" ",
E.button("-").use({ decrementClick: "click" })
]);
const counterModel = ({ incrementClick, decrementClick }) =>
instant(start => {
const increment = incrementClick.mapTo(1);
const decrement = decrementClick.mapTo(-1);
const changes = combine(increment, decrement);
const count = start(accum((n, m) => n + m, 0, changes));
return { count };
});
const counter = modelView(counterModel, counterView)();
runComponent("#mount", counter);
from turbine.
Btw examples are also outdated, (don't run).
from turbine.
Related Issues (20)
- list of objects bug HOT 2
- Todo example not working HOT 3
- Lack of generator return type inference HOT 5
- Document differences from other libraries/frameworks
- TodoMVC new items aren't focusing HOT 1
- Complexity, Verbosity HOT 7
- Help Wanted / Roadmap? HOT 1
- Manipulating DOM imperatively HOT 11
- The wrong word in readme
- Lists not working in some browsers HOT 5
- Code clarity
- GitHub Pages deployment is an empty page
- time.log() fails silently HOT 19
- when(...).log() error
- What's the difference between go and fgo? HOT 1
- Infix vs prefix notation HOT 2
- performStream vs performStreamLatest HOT 4
- 7GUIs Timer HOT 11
- div(Behavior.of(true)) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from turbine.