Get started with kefir CDN

MIT licensed

Kefir: library for handling asynchronous data streams, reactively.

Tags:
  • frp
  • bacon
  • bacon.js
  • kefir
  • kefir.js
  • functional
  • reactive
  • stream
  • streams
  • EventStream
  • Rx
  • RxJs
  • Observable

Stable version

Copied!

How to start using kefir CDN


// Include the Kefir library
const Kefir = require('kefir')(window, 'Kefir'); // Assuming you're using a browser

// Create a Kefir stream
const sourceStream = Kefir.fromEvent(document, 'click');

// Map the click event to a string message
const clickToMessageStream = sourceStream.map(event => 'Click event detected');

// Filter the message stream to only include messages that contain the word 'click'
const clickMessageStream = clickToMessageStream.filter(msg => msg.includes('click'));

// Combine the filtered stream with another stream (for example, a timer)
const combinedStream = Kefir.merge(clickMessageStream, Kefir.interval(1000).mapTo('Timer tick'));

// Subscribe to the combined stream and log the messages to the console
combinedStream.subscribe(msg => console.log(msg));
Copied!
Copied!

All versions