Giter Site home page Giter Site logo

Comments (4)

limemloh avatar limemloh commented on June 2, 2024

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.

janat08 avatar janat08 commented on June 2, 2024

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.

limemloh avatar limemloh commented on June 2, 2024

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.

janat08 avatar janat08 commented on June 2, 2024

Btw examples are also outdated, (don't run).

from turbine.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.