Ember Changesets

Michael Jan Schiumo
4 min readSep 14, 2021

When transitioning to working with Ember, I encountered a topic that seemed to pop up everywhere — Changesets. So, let’s take a look at what they are, and how to use them in our code.

What is a Changeset

A Changeset “represents a set of valid changes to be applied onto any Object (Ember.Object, DS.Model, POJOs, etc).” Basically, it is used to update values and properties within your code, and allows you to apply validations to ensure that invalid changes are not applied to the Object in question. This is an improvement over other methods of validations, which may validate the changes after they are applied, leading to invalid changes being applied to your Object.

How to Initialize a Changeset

Now that we understand the concept, let’s see a Changeset in action.

First, we import Changeset at the top of our file. Then, we can declare the Changeset with the underlying Object, and the validations that will be applied to it. Let’s use an example of a Person object that has a name, which we will track via the Changeset.

--

--