Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A representation of values over time
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
test
.gitignore
.testem.json
.travis.yml
LICENCE
README.md
accumulate.js
foldp.js
map.js
merge.js
package.json
source.js
state.js

README.md

signaal

build status dependency status

browser support

A representation of values over time

Example

var extend = require("xtend")

var map = require("signaal/map")
var Signal = require("signaal/state")
var Source = require("signaal/source")

var sunshine = Source(function (broadcast) {
    setInterval(broadcast, 1000)
})

var rain = Source(function (broadcast) {
    setInterval(broadcast, 3000)
})

var flower = Signal()
    .listen(sunshine, function (flower, shine) {
        return extend(flower, { shines: ++flower.shines })
    })
    .listen(rain, function (flower, water) {
        return extend(flower, { roots: ++flower.roots })
    })
    .initial({ shines: 0, roots: 0 })

var view = map(flower, function (flower) {
    return "" +
        "<div>" +
            "<span> Roots : " + flower.roots + " </span>" +
            "<span> Shines : " + flower.shines + " </span>" +
        "</div>"
})

var elem = document.createElement("div")
elem.innerHTML = view()
view(function (html) {
    elem.innerHTML = html
})
elem // =>

Installation

npm install signaal

Contributors

  • Raynos

MIT Licenced

Something went wrong with that request. Please try again.