All Projects → tweinfeld → backscatter

tweinfeld / backscatter

Licence: MIT license
Reactive extension for Backbone

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to backscatter

Fpgo
Monad, Functional Programming features for Golang
Stars: ✭ 165 (+870.59%)
Mutual labels:  reactive, collection
Datx
DatX is an opinionated JS/TS data store. It features support for simple property definition, references to other models and first-class TypeScript support.
Stars: ✭ 111 (+552.94%)
Mutual labels:  collection, model
Mithril Data
A rich data model library for Mithril javascript framework
Stars: ✭ 17 (+0%)
Mutual labels:  collection, model
realar
5 kB Advanced state manager for React
Stars: ✭ 41 (+141.18%)
Mutual labels:  reactive, model
TorXakis
A tool for Model Based Testing
Stars: ✭ 40 (+135.29%)
Mutual labels:  model
shyft
⬡ Shyft is a server-side framework for building powerful GraphQL APIs 🚀
Stars: ✭ 56 (+229.41%)
Mutual labels:  model
php-mvc
Mini framework para aplicaciones PHP con el patrón MVC
Stars: ✭ 35 (+105.88%)
Mutual labels:  model
semantic-python-overview
(subjective) overview of projects which are related both to python and semantic technologies (RDF, OWL, Reasoning, ...)
Stars: ✭ 406 (+2288.24%)
Mutual labels:  collection
springboot-rsocketjwt-example
Example of using JWT with RSocket and Spring Boot
Stars: ✭ 26 (+52.94%)
Mutual labels:  reactive
Quadcopter SimCon
Quadcopter Simulation and Control. Dynamics generated with PyDy.
Stars: ✭ 84 (+394.12%)
Mutual labels:  model
triggerflow
Event-based Orchestration of Serverless Workflows
Stars: ✭ 38 (+123.53%)
Mutual labels:  trigger
reactive-graphql
A GraphQL implementation based around RxJS, very well suited for client side only GraphQL usage
Stars: ✭ 58 (+241.18%)
Mutual labels:  reactive
db-safedelete
Attempts to invoke force delete, if it fails - falls back to soft delete
Stars: ✭ 16 (-5.88%)
Mutual labels:  model
grafikon
Timetables for model railway. Useful for meets with modules (like FREMO, Free-mo etc).
Stars: ✭ 19 (+11.76%)
Mutual labels:  model
NestedReact
BackboneJS compatibility layer for React-MVx MVVM framework.
Stars: ✭ 79 (+364.71%)
Mutual labels:  backbone
InterReact
Interactive Brokers reactive C# API.
Stars: ✭ 28 (+64.71%)
Mutual labels:  reactive
frontend
Frontend repository / Reactive realtime forum software (currently alpha).
Stars: ✭ 13 (-23.53%)
Mutual labels:  reactive
Awesome-Vision-Transformer-Collection
Variants of Vision Transformer and its downstream tasks
Stars: ✭ 124 (+629.41%)
Mutual labels:  backbone
IIITDMK Courses Repositories
A collection of course repositories of IIITDM Kancheepuram students
Stars: ✭ 25 (+47.06%)
Mutual labels:  collection
eudaq
EUDAQ Data Acquisition Framework
Stars: ✭ 22 (+29.41%)
Mutual labels:  trigger

backscatter

A reactive extension for Backbone Models

Backscatter is a small Backbone extension that notifies you of events anywhere in your Backbone model tree, no matter how deeply-nested they are. It's a great companion to React, since it enables you to carelessly trigger refreshes of your entire React tree whenever one or more base model(s) or their nested members change.

Installation

NPM

npm install backscatter

Types of intercepted events

Backscatter is a "catchall" listener. Anything that triggers an "all" event on your Model/Collection will be relayed by it.

createFactory(BackboneClass) -> BackboneClass

If you already have custom Backbone models and collections defined in your projects, you can extend them using "createFactory" so they can be used by Backscatter.

Backscatter.Model / Backscatter.Collection

An extension of Backbone's native Model and Collection which contains "backscatterOn" and "backscatterOff"

backscatterOn(handler)

handler will be called whenever the Model/Collection backscatterOn is invoked on or any of its decendants (close or remote) trigger an 'all' event.

The arguments passed to handler are Backbone's original 'all' event-handler arguments (target, event name etc.)

handler might be triggered several times sequently. For instance: Models that are members of a collection will trigger one event for the model, and another for the collection they're in, both will be intercepted by handler. Since you may be interested only in one of them, you can use underscore ".debounce()"

backscatterOff(handler)

Removes the binding to `handler'. It's best to call this when the view hosting your react component dies.

Examples

TodoMVC

Check out Backscatter's TodoMVC sample.

Sample

import _ from 'underscore';
import Backbone from 'backbone';
import Backscatter from './lib/backscatter.js';
import React from 'react';

class MyCustomComponent extends React.Component {
    render(){
        return <div>{ this.props.title }, { this.props.name }</div>
    }
}

// This model is an example of an existing model that's extended to enable backscatter updates (see "createFactory")
let MyExistingModel = Backbone.Model.extend({ defaults: { id: "name", name: "John Doe" } });

let A = new Backscatter.Model({ id: "title", "title": `Howdy` }),
    B = new (Backscatter.createFactory(MyExistingModel)),
    C = new Backscatter.Model({ "a": A, "b": B }),
    D = new Backscatter.Collection([C]);

let renderComponent = function(){
    React.render(React.createElement(MyCustomComponent, { title: D.at(0).get('a').get('title'), name: D.at(0).get('b').get('name') }), document.querySelector('body'));
};

// Set backscatter to render your component whenever there are changes to your model
D.backscatterOn(_.debounce(function(...[target, name]){
    console.log(`We've got a change on "${target.id}" with event name "${name}"`)
    renderComponent();
}));

// Perform a change somewhere in your model, and let backscatter react
setTimeout(function(){
    // Let's touch our model somewhere in a deeply nested location
    A.set({ "title": `Hello` })
}, 1000);

setTimeout(function(){
    // Let's touch our model somewhere else in a deeply nested location
    B.set({ "name": `Mark Smith` })
}, 2000);

renderComponent();
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].