npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ember-data-model-proxy

v0.0.0-beta.18

Published

An Ember wrapper for ember-data model to proxy changes to be applied at a later time

Downloads

2

Readme

ember-data-model-proxy

npm version Ember Observer Score Build Status Maintainability

Description

This ember addon provides the means to create/delete/edit ember-data models through a proxy, without applying the changes to the model itself. The model-proxy can then apply the changes to the model at a later date.

Installation

Like most ember addons, simply run ember install ember-data-model-proxy and you should be all set.

Docs

Utils

Model-Proxy

This is the model-proxy object in itself. It has all the functions/objects specific to it.

applyChanges

This applies the changes of the model-proxy to the model itself. It doesn't save the model though, it simply applies the modifications. It will go through each attribute/relationship of the model and update it with the value present in the proxy. It won't add new attributes not present in the model definition that were set in the proxy.

It receives only a single parameter, applyChangesToRelationships, which is true by default. This makes it so that every relationships that is proxied on the model will also have the applyChanges method called on them.

If the underlying model doesn't not exists, it will create one using the store and the model type that was passed to create the model-proxy.

save

This method calls applyChanges and then saves the current underlying model. It does not call the save of each relationship though, so you still need to call those manually. If requested enough, it can be changed to save the relationships too, but that behaviour would not be intuitive IMO.

set/get

The model-proxy uses the (set)unknownProperty functions exposed by ember to get/set the values in the proxy object without impacting the model. Any call to model-proxy.set will set the values in an underlying proxy object. Be careful not to set/get values present in the model-proxy itself though, because it will set/get those instead. For example, since "proxy" is the name of the underlying object containing the changes, calling model-proxy.set('proxy', 'some-value') will cause a whole lot of things to break. But eh, if you want to break it, that's the easy way to do it.

Services

Model-Proxy

The model-proxy service makes it easy to create model-proxies, with or without relationships. The main method it exposes is the CreateModelProxy() method:

CreateModelProxy

| Parameters | Type | Description | |---|:-------------:|:------:|:-------------:| | type | string (required) | Type of the model on which the proxy is based. This is usually the name of an ember-data model | | model | model | Base ember-data model to which the modifications will be applied. (Also initial state) | ||||| | returns | model-proxy | Returns a new model-proxy object |

Here, it's possible to pass only the type (service.createModelProxy('address-model') for example), which will result in a model-proxy with no base model. It can still be interacted with as usual, but now if you call applyChanges on that model-proxy, a record will be created using the type that was initially passed.

For more information on using ember-cli, visit https://ember-cli.com/.