Skip to content

Releases: iunu/mobx-async-store

It's been a while!

08 Jun 14:34
137863d
Compare
Choose a tag to compare

What's Changed

Full Changelog: v4.0.0...v4.9.1

Update to mobx 6

09 Jul 16:55
3c1024f
Compare
Choose a tag to compare

This does not change any API, but may cause conflicts / errors if you are using mobx < 6.0 in your application. For information on how to upgrade from mobx 5 to 6, see the mobx docs.

Changes to `add`

07 Apr 15:57
4dc7e2d
Compare
Choose a tag to compare

store.add has been very inconsistent in the past. First, it accepted any properties. Second, it would override relationships as simple properties. This could lead to some strange situations.

Consider a basic model Todo with relationships Category and Note

class Category extends Model {
  static type = 'categories'
}
class Note extends Model {
  static type = 'notes'
}
class Todo extends Model {
  static type = 'todos'
  @attribute(String) title = ''
  @observable highlighted
  @relatedToMany notes
  @computed get capTitle () {
    return this.title.toUpperCase()
  }
}

store.add could be used to set attributes, but everything else (relationships, computed properties, and non-defined properties) would be set as an unobserved properties. When accessing the object, these would be returned as mishmash of observed attributes and properties, and unobserved properties.

const todo = store.add('todos, {
  title: 'Take out trash',
  assigneeName: 'Me',
  highlighted: true,
  notes: [{ id: '1', type: 'notes' }],
  category: store.getOne('categories', '1'),
  capTitle: 'Take in Trash'
})

$> todo.title
=> Todo {
  title: 'Take out trash',             // observed attribute
  highlighted: true,                   // observed property (will not be serialized)
  assigneeName: 'Me',                  // unobserved text (not defined as an attribute)
  notes: [{ id: '1', type: 'notes' }]  // unobserved array with an object (relationship definition is overridden)
  category: Category { id: '1' }       // unobserved Category object (relationship definition is overridden)
  capTitle: 'Take in Trash'            // unobserved text (computed property is overridden)
}

With these changes, add will work differently:

  • it accepts attributes as well as relationships, and sets them correctly
  • relationships can be passed as either the id and type of an object, or the object itself
  • it will not accept anything that is not an attribute or a relationship
const todo = store.add('todos, {
  title: 'Take out trash',
  assigneeName: 'Me',
  highlighted: true,
  notes: [{ id: '1', type: 'notes' }],
  category: store.getOne('categories', '1'),
  capTitle: 'Take in Trash'
})

$> todo.title
=> Todo {
  title: 'Take out trash',          // observed attribute
  highlighted: undefined,           // observed property, can only be set directly (not by using `add`)
  assigneeName: undefined,          // unobserved property, can only be set directly (not by using `add`)
  notes: [Note { id: '1' }],        // observed relationship array with a Note object
  category: Category { id: '1' },   // observed relationship with a Category object
  capTitle: 'TAKE OUT TRASH'        // computed property (cannot be overridden)
}

mobx upgrade

31 Mar 12:53
2572796
Compare
Choose a tag to compare
v3.7.0

upgrade mobx to most recent 5.x version (#101)

v3.6.5: Revert "update add to accept relationships (#99)"

31 Mar 11:33
Compare
Choose a tag to compare
This reverts commit e1ff2e119a4a1435adb5f9a1331681fafd237e9c.

3.4.1

27 Feb 20:54
Compare
Choose a tag to compare
don't break up ids with quirky regex for findMany (#94)

Internal fixes

09 Feb 22:04
@sd sd
fa7a50f
Compare
Choose a tag to compare

Improved use of inverse relationships as a fallback for missing data.

Batch and group transactions

14 Dec 22:22
@sd sd
c1a488b
Compare
Choose a tag to compare
v3.2.0

extensions instead of customExtensions (#75)

Server Errors!

04 Sep 20:35
ff579bf
Compare
Choose a tag to compare

Adds server errors directly to their corresponding attributes in models.

Previously we had made the decision to lump all server errors onto a "server" attribute so that they would at least be accessible. Now, when errors come back from the API we parse the source pointer for each error to determine which attribute the error is for and add it in the same manner as our model validations. This is a breaking change, so 3.0 has arrived!

This also support errors for create/update requests using the JSONApi bulk extension. When these errors are returned, the pointer will contain an index that corresponds to the payload of the original request which is used to determine which object in the store the errors should be assigned to.

return a promise for findAll

23 Jul 23:45
5fa2a95
Compare
Choose a tag to compare

This contains a breaking change for findAll, one of the most commonly-used methods in the past. findAll returns a promise if it executes a fetch, but an array if it uses the cache. this is fine if fromServer is explicit, but otherwise the return object is ambiguous.