Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ember-buffered-proxy

Package Overview
Dependencies
Maintainers
7
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-buffered-proxy

An Ember Object Proxy with change buffering

  • 2.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
11K
decreased by-17.39%
Maintainers
7
Weekly downloads
 
Created
Source

ember-buffered-proxy

Build Status Ember Observer Score

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';

let content = {
  firstName: 'stefan'
};

let 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';

let content = {
  firstName: 'stefan'
};

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

// same as above

Compatibility

VersionMinimal Ember version required
> 2.1.03.13
> 1.0.13.8
0.8.0 - 1.0.12.15
< 0.82.5

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

Keywords

FAQs

Package last updated on 11 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc