Skip to content

v0.16.0

Compare
Choose a tag to compare
@ryanto ryanto released this 05 Apr 16:47
· 383 commits to master since this release

Breaking changes

This is the last release with breaking changes, we've settled on storefront's data loading API.

reloadWith has been renamed to sideload.

model.reloadWith is now model.sideload. reloadWith is deprecated, but will continue to work until we release version 1.0.0.

The method name sideload better communicates what storefront is actually doing, sideloading a model's relationships.

Load options

All of storefront's APIs now support reload and backgroundReload options. These allow you to control how the promise resolves and if network requests are made when data is already in the store.

The reload option will force storefront to always fetch data and return a blocking promise, even if data is already in the store.

this.store.loadRecords('post', { reload: true });
this.store.loadRecord('post', 1, { reload: true });
post.load('comments', { reload: true });
post.sideload('comments', { reload: true });

The backgroundReload option can be used to prevent storefront from making a network request if the data has already been loaded. This is useful for data that won't change during the application's lifecycle.

this.store.loadRecords('country', { backgroundReload: false });
this.store.loadRecord('country', 'US', { backgroundReload: false });
country.load('states', { backgroundReload: false });
country.sideload('states', { backgroundReload: false });

Upgrading from 0.15

Rename all instances of reloadWith to sideload.

Storefront users who want to upgrade from 0.14 will need to update any calls to loadAll in their code to loadRecords.

- return post.reloadWith('author,comments');
+ return post.sidelod('author,comments');

That's it! You're all set.