Skip to content

Releases: greena13/redux-and-the-rest

v1.0.0

16 Feb 17:41
Compare
Choose a tag to compare

Breaking changes

Action creators are now exported in their own object

Action creators returned by resources is now contained in an actionCreators object:

Before:

const { reducers, fetchUsers, getCollection } = resources({
  // ...

After:

const { reducers, actionCreators: { fetchUsers }, getCollection } = resources({
  // ...

Can no longer edit new resource items using the edit action creator

The edit action creator is no longer used to edit the new resource. This used to be useful in situations where you wanted to define a new resource item over several steps before saving it to the server. Now the new editNew action creator must be used for this.

Before:

const { reducers, fetchUsers, getCollection , newUser, editUser } = resources({
  name: 'user's
}, [ 'new', 'edit' ]);

dispatch(newUser('temp', { firstName: 'Foo', lastName: 'Bar' }));

// ...

dispatch(editUser('temp', { lastName: 'Baz' }));

After:

const { reducers, fetchUsers, getCollection , actionCreators: { newUser, editNewUser } } = resources({
  name: 'user's
}, [ 'new', 'editNew' ]);

dispatch(newUser('temp', { firstName: 'Foo', lastName: 'Bar' }));

// ...

dispatch(editNewUser('temp', { lastName: 'Baz' }));

See Edit the new resource item in the store for more information.

resourceType has been replaced by projection

Replaced resourceType (a previously undocumented feature) with a projection object for items and collections.

New features

  • The params argument is now optional for create*() and new*() action creators. A temporary id is automatically generated if one isn't specified, and the new item can continue to be accessed using the getNewItem() helper function.
  • Added a localOnly option for when you do not want to retrieve or save data to a remote API
  • Added a syncedAt attribute to the status information for resource items and collections
  • Added a occurredAt attribute to the status information when a resource item or collection is in an error state
  • Added TypeScript definitions for all module exports
  • Add a new requestAdaptor option for adapting resource items and collections before passing them to be put into the body of create and update requests.

Improvements

  • Readme improvements and corrections
  • Added a contents section to the Readme
  • Updated test and development dependencies
  • Updated test suite to fix some inherent problems
  • Internal refactoring to make the source code easier to follow
  • Improved the specificity of developer warning messages to make them clearer

v0.1.0

26 Jul 07:03
Compare
Choose a tag to compare

Bugfixes

  • Allow keyBy to receive an array value, to enable keying items by more than one attribute (either available at the time of creation/fetching or returned by the server).

New features

  • Add getItem(), getCollection() and getNew() helper functions to simplify retrieving things from the store and create an additional level of abstraction that should isolate end users from breaking changes if the underlying data schema changes.

v0.0.4

10 Jul 07:21
Compare
Choose a tag to compare

Breaking changes

  • Calls to fetch<Resources> now override the current collection's values. Previously it used to merge the new values with the old. Currently there is no way to restore the old behaviour, so it is not recommended to upgrade to this version if this is a problem.
  • The third argument for fetch<Resource> and fetch<Resources> action creators that was previously used to configure only the Request object used to fetch the resources has now been multipurposed into a general run-time configuration object. When migrating to this version, you now need to namespace your previous configuration with request. e.g. headers: { foo: 'bar' } now becomes { request: { headers: { foo: 'bar' } }
  • The third argument for create<Resource> and new<Resource> has also been repurposed as a general run-time configuration object. When migrating to this version, to maintain the same behaviour, you need to namespace the collection keys under unshift: e.g. { order: 'newest' } now becomes { unshift: { order: 'newest' } }.

New features

  • create<Resource> and new<Resource> now allow you to explicitly define how the resource should be added to collections. It accepts the following options:
    ** push: Pushes the new item to the end of the collection. e.g. newUser('temp123', { ... }, { push: { order: 'oldest' })
    ** unshift: Adds the new item to the beginning of the collection. e.g. newUser('temp123', { ... }, { unshift: { order: 'newest' })
    ** invalidate: Clears the collection so that it will be fetched again from the server. e.g. newUser('temp123', { ... }, { invalidate: { order: 'random' })
  • There is now a configure method that can be used for setting a global configuration object that will apply to all resources. Currently it is of limited use, but will be built upon and refined in future releases.

v0.0.3

08 Jul 07:17
Compare
Choose a tag to compare

Breaking changes

  • Add isomorphic-fetch as a peer dependency
  • Change clearNew() to only clear the newest item if it has a status.type of NEW (always clear newItemKey)

Documentation

  • Some additions to the Readme file

v0.0.2

06 Jul 08:12
Compare
Choose a tag to compare

Breaking changes

  • Now only the keyBy attribute is used to index items. So any other attributes passed as an object to any of the action creators are only used in the url to fetch or create the item (for example) - not in how the item is merged into the store. E.g. createUser({id: 1, townId: 2}) may send a request like POST http://www.example.com/towns/2/users, but it will be stored in users.items[1] (and NOT users.items['id=1.townId=2'] as before).

Non-breaking changes

  • Add a default value of 'id' to keyBy