Skip to content
An Ember Proxy the enables change buffering
Branch: master
Clone or download
Latest commit d7f96ce Apr 24, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
addon
app Initial Commit from Ember CLI v0.1.2 Oct 31, 2014
config
tests Upgrades for cli, source, and deps to 2.15 (#34) Nov 21, 2017
vendor
.editorconfig
.ember-cli Initial Commit from Ember CLI v0.1.2 Oct 31, 2014
.eslintrc.js Upgrades for cli, source, and deps to 2.15 (#34) Nov 21, 2017
.gitignore
.npmignore
.travis.yml Tweak README and ember-try config Apr 24, 2018
.watchmanconfig Upgrade to ember-cli 2.5 and update to ES2015 May 25, 2016
CHANGELOG.md
LICENSE.md Upgrade to ember-cli 2.5 and update to ES2015 May 25, 2016
README.md
ember-cli-build.js
index.js
package.json
testem.js
yarn.lock

README.md

ember-buffered-proxy Build Status

An Ember Object Proxy (and mixin) that enables change buffering. Ever need to "hold back" property changes before they propagate? If so, this may be the addon for you.

Usage

ember install ember-buffered-proxy
import BufferedProxy from 'ember-buffered-proxy/proxy';

var content = {
  firstName: 'stefan'
};

var buffer = BufferedProxy.create({
  content: content
});

buffer.get('firstName'); // => 'stefan'
buffer.set('firstName', 'Kris');

buffer.get('firstName'); // => 'Kris'
buffer.get('content.firstName'); // => 'stefan'

buffer.get('hasChanges'); // => true
buffer.buffer; // => (get an object describing changed keys) -- {"firstName": "Kris"}

buffer.applyBufferedChanges();

buffer.get('firstName'); // => 'Kris'
buffer.get('content.firstName'); // => 'Kris'
buffer.get('hasChanges'); // => false

buffer.set('firstName', 'Luke');
buffer.get('firstName'); // => 'Luke'
buffer.get('content.firstName'); // => 'Kris'
buffer.hasChanged('firstName'); // => true

buffer.discardBufferedChanges();

buffer.get('firstName'); // => 'Kris'
buffer.get('content.firstName'); // => 'Kris'
buffer.hasChanged('firstName'); // => false

// Below demonstrates that applyBufferedChanges and discardBufferedChanges
// can take an optional array of keys.

buffer.set('email', 'example@example.com');
buffer.get('email'); // => 'example@example.com'
buffer.get('content.email'); // => undefined

buffer.set('address', '123 paradise road');
buffer.get('address'); // => '123 paradise road'
buffer.get('content.address'); // => undefined

buffer.applyBufferedChanges(['email']); // Only apply the email from the buffer

buffer.get('email'); // => 'example@example.com'
buffer.get('address'); // => '123 paradise road'
buffer.get('content.email'); // => 'example@example.com'
buffer.get('content.address'); // => undefined

buffer.setProperties({
  email: 'sample@sample.com',
  address: '1717 rose street'
});

buffer.discardBufferedChanges(['address']); // Discard only the address property from the buffer

buffer.get('email'); // => sample@sample.com
buffer.get('address'); // => undefined

You can also use these shorter method names

buffer.discardChanges(); // equivalent to buffer.discardBufferedChanges()
buffer.applyChanges();   // equivalent to buffer.applyBufferedChanges()

Or you can grab the mixin directly

import BufferedMixin from 'ember-buffered-proxy/mixin';

var content = {
  firstName: 'stefan'
};

var buffer = ObjectProxy.extend(BufferedMixin).create({
  content: content
});

// same as above

development

Installation

  • git clone this repository
  • yarn install
  • bower install

Running

Running Tests

  • ember test
  • ember test --server

Building

  • ember build

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

You can’t perform that action at this time.