Skip to content

Latest commit

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Reactive One-way Data Binding using JS Setters

Instantiate a data binding model with optional name and and set up a subscriber.

import{Model}from'./data-bind.js'constmodel=newModel('my-model')constsubscriber={value: 'nothing'}

Define a property on the model and establish a one-way data binding to a property of the subscriber.

model.bind('someProperty',subscriber,'value')

Each new assignment of the model's property is reflected to all its subscribers.

model.someProperty='hello'// subscriber.value === 'hello'model.someProperty='world'// subscriber.value === 'world'model.someProperty='!'// subscriber.value === '!'

The model also keeps track of all assigned values in a history.

console.log(model.history.someProperty)

Output:

['hello', 'world', '!']

For a working example with ui integration take a look at index.html.

About

a small JS library for reactive object-to-object data binding with JS setters

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages