{"id":18532331,"url":"https://github.com/triptyk/ember-immer-changeset","last_synced_at":"2026-02-11T01:02:28.275Z","repository":{"id":41988190,"uuid":"386544658","full_name":"TRIPTYK/ember-immer-changeset","owner":"TRIPTYK","description":"Ember addon that leverages ImmerJS to provide an immutable changeset. It enables tracking, validating, and managing changes in data with ease, offering rollback capabilities and error handling. Ideal for form data management and state consistency in Ember apps.","archived":false,"fork":false,"pushed_at":"2026-02-02T12:36:12.000Z","size":2405,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2026-02-06T22:34:10.977Z","etag":null,"topics":["changeset","changesets","ember","ember-changeset","emberjs","immerjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TRIPTYK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-07-16T07:10:38.000Z","updated_at":"2026-02-02T12:35:40.000Z","dependencies_parsed_at":"2025-04-23T11:27:02.952Z","dependency_job_id":null,"html_url":"https://github.com/TRIPTYK/ember-immer-changeset","commit_stats":null,"previous_names":["triptyk/ember-form-changeset-validations","triptyk/ember-immer-changeset","triptyk/ember-form-changeset"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/TRIPTYK/ember-immer-changeset","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TRIPTYK%2Fember-immer-changeset","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TRIPTYK%2Fember-immer-changeset/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TRIPTYK%2Fember-immer-changeset/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TRIPTYK%2Fember-immer-changeset/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TRIPTYK","download_url":"https://codeload.github.com/TRIPTYK/ember-immer-changeset/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TRIPTYK%2Fember-immer-changeset/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29323964,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-11T00:34:26.354Z","status":"ssl_error","status_checked_at":"2026-02-11T00:34:09.494Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["changeset","changesets","ember","ember-changeset","emberjs","immerjs","typescript"],"created_at":"2024-11-06T19:05:51.094Z","updated_at":"2026-02-11T01:02:28.219Z","avatar_url":"https://github.com/TRIPTYK.png","language":"TypeScript","readme":"# Ember-immer-changeset\n\n[![CI](https://github.com/TRIPTYK/ember-immer-changeset/actions/workflows/ci.yml/badge.svg)](https://github.com/TRIPTYK/ember-immer-changeset/actions/workflows/ci.yml)\n[![Ember Observer Score](https://emberobserver.com/badges/ember-immer-changeset.svg)](https://emberobserver.com/addons/ember-immer-changeset)\n[![npm version](https://badge.fury.io/js/ember-immer-changeset.svg)](https://badge.fury.io/js/ember-immer-changeset)\n\n`ember-immer-changeset` is an Ember addon that provides a robust changeset implementation using [Immer](https://immerjs.github.io/immer/). It allows you to easily manage, apply, and rollback changes in your data with immutability guarantees.\n\n## Key Features\n\n- **Immutable Data**: Use Immer to manage immutable changes to data objects.\n- **Track Changes**: Automatically track changes and patches made to your data.\n- **Validation**: Integrate validation logic and manage errors easily.\n- **Revertible**: Rollback changes or properties to previous states.\n- **Events**: Hooks for listening to changes on specific properties.\n\n## Minimum Requirements\n\n- Ember.js v4.4 or above\n- Ember CLI v4.4 or above\n- Node.js v16 or above\n\n## Installation\n\nTo install this addon, run:\n\n```bash\nember install ember-immer-changeset\n```\n\n## Documentation\n\nFor full API documentation and examples, visit the [ember-immer-changeset documentation](https://triptyk.github.io/ember-immer-changeset/).\n\n## Example Usage\n\n```ts\nimport ImmerChangeset from 'ember-immer-changeset';\n\n// Define your data object\nconst userData = {\n  id: 1,\n  name: 'John Doe',\n  email: 'johndoe@example.com',\n  age: 30,\n};\n\n// Create a new changeset instance\nconst userChangeset = new ImmerChangeset(userData);\n\n// Make changes\nuserChangeset.set('name', 'Jane Doe');\nuserChangeset.set('age', 31);\n\n// Check if there are changes\nconsole.log('Is Dirty:', userChangeset.isDirty); // true\n\n// Get the changes made\nconsole.log('Changes:', userChangeset.changes); // [{ key: 'name', value: 'Jane Doe' }, { key: 'age', value: 31 }]\n\n// Validate changes\nawait userChangeset.validate((draftData) =\u003e {\n  userChangeset.removeErrors();\n  if (draftData.age \u003c 18) {\n    userChangeset.addError({\n      originalValue: draftData.age,\n      value: 18,\n      key: 'age',\n    });\n  }\n});\n\n// If valid, apply and save changes\nif (userChangeset.isValid) {\n  userChangeset.execute();  // Apply changes\n  console.log('Updated User Data:', userChangeset.data);  // Updated data\n  \n  userChangeset.save();  // Save changes permanently\n  console.log('User Data after Saving:', userChangeset.data);\n}\n```\n\n## API Overview\n\n### `ImmerChangeset\u003cT\u003e`\n\nThis class represents a changeset for a given data object. It offers the following core methods:\n\n- **`set(key: string, value: any)`**: Apply a change to a property.\n- **`get(key: string)`**: Get the current value of a property.\n- **`execute()`**: Apply all changes to the original data.\n- **`rollback()`**: Revert changes back to the original state.\n- **`rollbackProperty(key: string)`**: Revert a specific property.\n- **`addError(error: ValidationError)`**: Add an error for a specific field.\n- **`removeError(key: string)`**: Remove an error for a specific field.\n- **`validate(validationFunction)`**: Validate the changeset with a custom validation function.\n- **`onSet(callback)`**: Register a callback that triggers on any set operation.\n\n### Event Hooks\n\nYou can register event listeners to trigger when changes are made:\n\n```ts\nconst off = userChangeset.onSet((key, value) =\u003e {\n  console.log(`Property ${key} set to ${value}`);\n});\n\n// To remove the event listener\noff();\n```\n\n## Additional Utilities\n\n### `isChangeset`\n\nThis utility function checks whether a given object is an instance of `ImmerChangeset`. It is useful when you want to ensure that an object is a valid changeset before interacting with it.\n\n```ts\nimport { isChangeset } from 'ember-immer-changeset';\nimport ImmerChangeset from 'ember-immer-changeset';\n\nconst userChangeset = new ImmerChangeset(userData);\n\n// Check if the object is a changeset\nconsole.log(isChangeset(userChangeset)); // true\n```\n\n**Function signature:**\n\n```ts\nfunction isChangeset(obj?: InstanceType\u003cany\u003e): boolean;\n```\n\n- **`obj`**: The object to check.\n- **Returns**: A boolean indicating if the object is an instance of `ImmerChangeset` or has a `__changeset__` property.\n\n---\n\n### `changeset-get` Helper\n\nThe `changeset-get` helper is an Ember template helper that retrieves the value of a specific property from an `ImmerChangeset` instance. This is particularly helpful when you want to access changeset properties within templates.\n\n```hbs\n{{changeset-get this.userChangeset \"name\"}}\n```\n\n**Function signature:**\n\n```ts\nfunction changesetGet([changeset, key]: [ImmerChangeset | undefined, string]): any;\n```\n\n- **`changeset`**: The `ImmerChangeset` instance.\n- **`key`**: The property name to retrieve from the changeset.\n- **Returns**: The value of the specified property.\n\nUsage in a template:\n\n```hbs\n{{changeset-get this.userChangeset \"email\"}}\n```\n\nThis helper allows easy access to the values of properties on the changeset directly within Ember templates.\n\n## Contributing\n\nContributions are welcome! Please see the [CONTRIBUTING.md](https://github.com/TRIPTYK/ember-immer-changeset/blob/main/CONTRIBUTING.md) for guidelines.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](https://github.com/TRIPTYK/ember-immer-changeset/blob/main/LICENSE) file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriptyk%2Fember-immer-changeset","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftriptyk%2Fember-immer-changeset","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftriptyk%2Fember-immer-changeset/lists"}