Code Monkey home page Code Monkey logo

af-databinding's Introduction

AF DataBinding CCC

Codacy Badge npm version

AF DataBinding is a up coming Data Binding module for ApplicationFrame.

This library allows fast, high performant and extensible data binding. With the integrated extension API it is possible to add custom bindings as desired.

Details

Bindings are processed synchronously but view updates happen asynchronously. This allows the binding system to operate fast and non blocking. Users also don't have to worry about accidentally starting multiple update cycles, since there will always be just one update cycle at the end of a call stack

How To

Everything is constructed from html templates. To use data binding on an element simply move the element into a html template.

<template id="my-binding-snippet">
    <div class="item">{{itemText}}</div>
</template>

Bind a Template

In order to bind data to a template it is required to tell the data binding engine about the template

import DataBinding from 'af-DataBinding';

let scope = {
    itemText: 'test',
};

scope = DataBinding.makeTemplate('#my-binding-snippet', scope).scope;

This short snippet allows to get the template processed and receive an instance of it. Since it is often not desired to only instantiate a template, a specific attribute has been created.

<template id="my-binding-snippet" replace>
    <div class="item">{{itemText}}</div>
</template>

The replace attribute tells the binding engine to automatically replace the template in the DOM with the new instance. Therefore this would result in the following HTML snippet.

<div class="item">test</div>

repeat a template

the current implementation of the engine allows to automatically repeat a part of a template. This can be achieved with the following construct.

<template id="something-something" replace>
    <ul>
        <template bind-repeat="item in items">
            <li>{{item}}</li>
        </template>
    </ul>
</template>

Elementary in this example is the inner template element. It will get automatically repeated, for every element in the items array on the scope, when the surrounding template gets instantiated.

af-databinding's People

Contributors

dependabot[bot] avatar greenkeeper[bot] avatar titannano avatar

Stargazers

 avatar

Watchers

 avatar  avatar

af-databinding's Issues

isolate template recycling

For performance purposes template recycling should happen interdependently. Each template chooses to recycle on it's own. There shouldn't be any global recycling anymore.

Style binding has to trigger scope update

Currently the style binding doesn't trigger a scope update and just assigns the style and layout values to the scope.
This causes the view to be inaccurate since no re render happens after the new values are available.

Bindings Tree

Store bindings in a tree. This way we can also store relationships between bindings and preserve the node structure in which the binding where found. Once bindings are stored in a tree format it will be easy to determine which bindings should be updated and which not.

Finish Binding API

The binding API should be finished before the stable release. This API will enable external bindings.

Provide nodeList in createTemplateInstance result

When using the replace attribute on templates, the result of createTemplateInstance contains an empty document fragment which is utterly useless. It would be better to return an array of all the instantiated nodes.

Implement more verbose logging

we should have verbose logging behind a flag. This should give developers the possibility to have more insight on whats going on inside the engine if needed.

advance the attribute parser

The attribute parser should be improved to be able to understand binding names like this: bind-event(). This binding name should translate to any binding like this: bind-event(click)="view.onClick" while the new parameter in the parentheses will be passed into the bindings constructor() method along with the other parameters.

Server-side Rendering

implement server-side rendering. It should be possible to run the entire databinding on the server and then send the static html with the application state down to the client.

DOM less testing

From @TitanNano on March 10, 2016 8:21

Create fake copies of the main methods so applications and systems can be tested without actually interfacing with the DOM.

  • analyze the data binding interface and add all the required methods
  • write fake implementations
  • new interface method to enable test mode
  • write test

Copied from original issue: TitanNanoDE/ApplicationFrame#10

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.