Noble Programming Mantra

    pancetta

    0.1.0 • Public • Published

    Pancetta

    A lightweight FRP library based on Bacon.js

    Usage

    var input = Pancetta.fromEvent($('#new-message'), 'keydown')
     
    input.filter(function(event) {
      return event.which === 13;
    }).map(function(event) {
      return event.target.value;
    }).flatMap(function(message) {
      return Pancetta.fromPromise($.post('/restAPI', message));
    }).scan(function(messages, newMessage) {
      return messages.concat([newMessage]);
    }, []).map(Handlebars.compile(
      '{{#each this}}<li>{{this}}</li>{{/each}}'
    )).subscribe(function(markup) {
      $('#messages').html(markup);
    });
    var submits = Pancetta.fromEvent($('#my-form'), 'submit').do(function(event) {
      event.preventDefault();
    }).map(function(event) {
      return $(event.target).serialize();
    }).flatMap(function(data) {
      return Pancetta.fromPromise($.post('/new-submission', data));
    }).scan(function(submissions, submission) {
      return submissions.concat([submission]);
    }, []);
     
    submits.subscribe(function(submissions) {
      React.renderComponent(SubsView({submissions: submissions}), $('#subs'));
    });

    Keywords

    none

    Install

    npm i pancetta

    DownloadsWeekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • l8d