Skip to content

mailaneel/immutable-store2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#Immutable Store

#Collection

import {Store, Model, Collection} from 'immutable-store';
class Comments extend Collection{
}

var comments = new Comments();
var comment = comments.insert({id: 1, likes: 4});

// immutable
var updatedComment = comments.update(1, {likes: 4});
console.log(comment === updatedComment) // logs true

updatedComment = comments.update(1, {likes: 5});
console.log(comment === updatedComment) // logs false

//events
comments.on('change', function(comments){
// triggers for every update, insert, remove
});

#Model

class Comment extends Model{
}

var comment = new Comment();
comment.set({id:1, likes: 5});
comment.get('likes'); // returns 5
comment.remove('likes');
comment.clear();

comment.on('change', function(comment){

});

About

wrapper around seamless-immutable

Resources

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors