Coder Social home page Coder Social logo

triptyk / ember-immer-changeset Goto Github PK

View Code? Open in Web Editor NEW
0.0 7.0 0.0 2.33 MB

An ember addon providing a changeset that uses ImmerJS internally

License: MIT License

JavaScript 27.29% TypeScript 67.03% Handlebars 0.37% HTML 5.17% CSS 0.14%
changeset ember-changeset immerjs typescript changesets

ember-immer-changeset's Introduction

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: '[email protected]',
  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);
}

ember-immer-changeset's People

Contributors

amauryd avatar dramixdw avatar ember-tomster avatar remadex avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-immer-changeset's Issues

In formconfig, add a pre-config key to set value before testing

create: {
          -->preConfigTest: `this.set('${name}Options', ['Tadam', 'Bidule']);`,
          checkValueAssert: `assert.dom('${selector} button').containsText('option2')`,
          fillValueHelper: `
            await click('${selector} button');
            await click("[data-test-option='1']");
          `,
          fillValueHelperImport: `import click from '@ember/test-helpers/dom/click'`,
          saveFunctionAssert: `assert.strictEqual(changeset.get("${name}"), )`,
},

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.