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

ember-immer-changeset

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-immer-changeset

A changeset library for emberJS using ImmerJS.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Ember-immer-changeset

CI Ember Observer Score npm version

Minimum Requirements

  • Ember.js v4.4 or above
  • Ember CLI v4.4 or above
  • Node.js v16 or above

Installation

ember install ember-immer-changeset

Documentation

https://triptyk.github.io/ember-immer-changeset/

Example

const userData = {
  id: 1,
  name: 'John Doe',
  email: 'johndoe@example.com',
  age: 30,
};

const userChangeset = new ImmerChangeset(userData);

// Display the initial user data
console.log('Initial User Data:', userChangeset.data);

// Make changes to the user data using the set method
userChangeset.set('name', 'Jane Doe');
userChangeset.set('age', 31);

// Check if there are changes
console.log('Is Dirty:', userChangeset.isDirty);

// Get the changes made
console.log('Changes:', userChangeset.changes);

await userChangeset.validate((draftData) => {
  userChangeset.removeErrors();
  console.log('Validating:', draftData);
  if (draftData.age < 18) {
    userChangeset.addError({
      originalValue: draftData.age,
      value: 18,
      key: 'age',
    });
  }
});

if (userChangeset.isValid) {
// Apply the changes to the original data
userChangeset.execute();

// Display the updated user data
console.log('Updated User Data:', userChangeset.data);

// Save the changes
userChangeset.save();

console.log('Is Dirty:', userChangeset.isDirty);

// Display the final user data after saving
console.log('User Data after Saving:', userChangeset.data);
}

Keywords

FAQs

Package last updated on 26 Nov 2023

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