Coder Social home page Coder Social logo

ember-history's Introduction

ember-history

Undo / Redo for Emberjs

Inspired by https://github.com/pangratz/ember-memento, however my implementation is for global History and not for individual objects (though it works with just one object as well)

Usage

App = Ember.Application.create({});

obj = Ember.Object.create(Ember.History, {
    _trackProperties: 'width height list'.w(),
    width: '100px',
    height: '50px',
    list: ['item3','carrot','car']
});

obj2 = Ember.Object.create(Ember.History, {
    _trackProperties: 'name surname'.w(),
    name: 'Ignas',
    surname: 'Bernotas',
});

obj2.set('name','Matthew');
obj.set('height','100px');
obj.set('list', ['item1']);
obj2.set('surname', 'Parry');

History.undo(); // surname is now back to Bernotas
History.undo(); // list is now back to ['item3','carrot','car']
History.undo(); // height is now 50px
History.undo(); // name is now Ignas
History.redo(); // name is now Matthew
History.redo(); // height 100px
History.redo(); // list is ['item1'] again
History.redo(); // surname is Parry again

You can also disable the history for a while

History.disable();
obj.set('height','300px'); //This won't push a new history state
History.enable();
obj.set('height','300px'); //This will

And you can also clear the states

History.clear()

License

This is licensed under MIT. See license.txt

ember-history's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

actuosus mnutt

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.