Code Monkey home page Code Monkey logo

avers-js's People

Contributors

werehamster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

avers-js's Issues

Support for flushing changes of specific objects

Instead of using a global Object.observe() callback, store it in the object that is being observed (under a private property). Then provide Avers.flushChanges(obj, recursive) to flush changes of a specific object.

Support nullable variant properties

I consider it a bug in the parser if it crashes when it can't decode a variant property. It should instead set the property to null. migrateObject can then take care of setting it to the default value if one is provided.

Stop polluting prototype with avers-specific functions

Now that we've moved aversProperties to a private property and no longer expose it to users of the library, we should consider the same with event functions (on, listenTo, trigger etc).

We can expose the event functions through the Avers module. However, they create an _events property which is used to store callbacks that are attached to the object. What I have in mind is to store them in a WeakMap instead. It would probably have a small performance impact. Will need to benchmark it.

Use metaprograming to implement a fromJSON function

We have all the information about the properties in this._modelProperties. Use that to parse the JSON and assign values.

This might not always be possible, eg. when a property has a polymorphic type. Provide hooks so that derived classes can override the parser.

A typo in README

There is a typo in README.md:

Typo: At this date (5015-07-18) only Chrome supports Object.observe.

Add support for nullable properties

Avers.define* functions will get a new optional argument which will be used as the default value. The absence of the optional argument will make the field nullable. If a default value is provided and the field is null, then Avers.migrateObject will initialize the property with a clone of the default value.

TODO: figure out what to do for variant properties.

Examples:

// Primitive property:
var default = 'default value';
Avers.defineProperty(Foo, 'field', default);

// Object property:
var default = Avers.mk(Bar, { test: 'one' });
Avers.defineObject(Foo, 'field', Bar, default);

// Variant property:
var default = Avers.mk(Bar, { test: 'one' });
Avers.defineVariant(Foo, 'type', 'content', { bar: Bar, baz: Baz }, default);

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.