JSPM

signalize

0.2.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q20228F

Signals in a functional reactive style

Package Exports

  • signalize

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (signalize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

signalize

Build Status

Functional Reactive Programming (FRP) is a programming paradigm for working with time-varying values, better capturing the temporal aspect of mutable state. Signal is a data structure representing a time-varying value. For example, consider the position of the mouse. The signal mousePosition represents current mouse position. When the mouse moves, the value changes automatically.

Signals can also be transformed and combined without typical hazards of the stateful programs.

Example

Signal is very low level construct that can be used to create signals from scratch:

var signal = require("signalize/signal")
var time = signal(function(next) {
  setInterval(function() {
    next(Date.now())
  }, 1000)
})

Signals implement Watchables abstraction which allows one to subscribe and unsubscribe from signal changes:

var watch = require("watchables/watch")
var unwatch = require("watchables/unwatch")

var end = Date.now() +  1000 * 5
watch(time, function onTimechange(value) {
  console.log(value)
  if (end - value <= 0) unwatch(time, onTimechange)
})

// => 1352077824718
// => 1352077825719
// => 1352077826720
// => 1352077827721
// => 1352077828722
// => 1352077829723

Install

npm install signalize