Skip to content

Commit 27b29db

Browse files
author
Vlad Balin
committed
Merge remote-tracking branch 'refs/remotes/origin/develop'
Conflicts: README.md
2 parents 0089062 + 5610493 commit 27b29db

File tree

14 files changed

+3535
-77
lines changed

14 files changed

+3535
-77
lines changed

README.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
# What it is
2-
3-
It's modern data framework, mostly backward compatible with backbone.js and can be used as drop-in backbonejs replacement.
4-
5-
Compared to `backbonejs`, it's has order of magnitude faster model updates, and support all the features which could be found
6-
in state of the art model frameworks through lightweight and declarative attribute type annotations.
7-
8-
Browse complete documentation here: http://volicon.github.io/backbone.nestedTypes/
9-
10-
## Release 1.1.x highlights
1+
# Getting Started
112

123
master: [![Master Build Status](https://travis-ci.org/Volicon/backbone.nestedTypes.svg?branch=master)](https://travis-ci.org/Volicon/backbone.nestedTypes)
134
develop: [![Develop Build Status](https://travis-ci.org/Volicon/backbone.nestedTypes.svg?branch=develop)](https://travis-ci.org/Volicon/backbone.nestedTypes)
145

6+
Version 1.1.5 highlights:
7+
8+
- Fixed incompatibilities with backbone 1.2.x by removing backbone dependency, effective now and forever. Currently, stable backbone 1.1.2 is linked in.
159
- npm package name is changed to just 'nestedtypes'. Thus, `npm install nestedtypes`.
16-
- It export all the stuff which is required to use it as drop-in backbonejs replacement in your project.
10+
- Can be used as drop-in backbonejs replacement in your project.
1711
- Models has reference to the parent model through `this._owner`
18-
- When the same model is shared between two other models, attempt to serialize the model which is not an owner will result in [Serialization Error] warning. In most of the cases, this warning is the sign of weird errors, because after loading data this shared models won't be shared any more.
12+
- When the same model is shared between tho other models, attempt to serialize the model which is not an owner will result in [Serialization Error] warning. In most of the cases, this warning is the sign of weird errors, because after loading data this shared models won't be shared any more.
1913
- Collections has new `changes` event, which can be used directly on collection instead of 'add remove change reset'. It's efficient, and fired only once during compound changes.
2014
- There are Collection.transaction( func ) method which can be used ad-hoc to group sequence of changes coming from inside of func to the single transaction, thus, firing just one 'changes' event. Helpful for reducing an amount of renders.
2115
- Every method declared on Collection can be turned to be transactional when its definition is wrapped in Nested.transaction.
16+
- Experimental features:
17+
- lazily evaluated hard references `Model.take( ref )` and `Collection.take( ref )`. ref is the reference like in
18+
- attribute proxies for mixing in attributes, `a : MyModel.proxy()`. `a` members will be directly accessible in owner model.
2219
- There are completely new mechancs of Stores, which will be documented later, and will allow us to refactor collections with mutual references which has to be requested together (such as users-roles-channelSets). It will be documented later.
2320

2421
Major change you need to do now:
@@ -36,7 +33,15 @@ Nested.store = new Nested.LazyStore.defaults({
3633
Why? Because now Stores are first-class objects in the system, they can be created with `new`,
3734
they supports hierarchical lookups, they may have different transports, and more. The more about it later.
3835

39-
## Features
36+
Browse complete documentation here: http://volicon.github.io/backbone.nestedTypes/
37+
38+
## What it is
39+
40+
It's modern data framework, mostly backward compatible with backbone.js and can be used as drop-in backbonejs replacement.
41+
42+
Compared to `backbonejs`, it's has order of magnitude faster model updates, and support all the features which could be found
43+
in state of the art model frameworks through lightweight and declarative attribute type annotations.
44+
4045
### Complex attribute types
4146

4247
* Cross-browser handling of Date attribute type.

docs/hardrefs.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Model.take( ref ) or Collection.take( ref )
2+
3+
- Resolved with ref value, evaluated on first read attempt
4+
- Non-serializable by default
5+
- Non-assignable
6+
- Assugnment with `null` delete cached ref value, forcing ref evaluation next time.
7+
- Change events bubble up by default
8+
9+
Valid ref values:
10+
- store reference
11+
- model reference relative to `this`
12+
- direct reference to object
13+
- function, returning the value
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
(!) UNIVERSAL DATABINDING (!)
2+
3+
4+
5+
// for boolean
6+
collection.toggler( model )
7+
get : m in collection
8+
set( true )
9+
10+
{ encoders.map( encoder => (
11+
<Checklist checked={ selected.toggler( encoder ) } />
12+
))}
13+
14+
// for inputs
15+
model.bind.attr
16+
17+
// for radio
18+
model.bound.selected.eql( x )
19+
get : a === x,
20+
set( true ) : a = x
21+
set( false ): a = null
22+
23+
// for clicks
24+
model.setter.selected.to( x )
25+
get : a = x
26+
27+
model.setter.selected.toggle( y )
28+
29+
30+
model.setter( 'attr', x )
31+
model.setter( 'attr' )
32+
model.toggler( 'attr', x )
33+
34+
35+
function to( x ){
36+
var setter = this;
37+
return function(){ setter( x ); }
38+
}
39+
40+
function toggle( x ){
41+
var setter = this;
42+
return function( y ){
43+
,,,,
44+
return setter() === y;
45+
}
46+
}
47+
48+
makeSetter( self, name ){
49+
var f = function( x ){
50+
return arguments.length ? self[ name ] = x : self[ name ];
51+
};
52+
53+
f.to = to;
54+
}
55+
56+
setter : function(){
57+
if( this._setters )
58+
var setters = {}, self = this;
59+
for( var name in this.attributes ){
60+
setters[ name ] = makeSetter( name );
61+
}
62+
63+
return setters;
64+
}
65+
66+
function( x ){
67+
68+
}

0 commit comments

Comments
 (0)