Skip to content

v6.0.0

Compare
Choose a tag to compare
@joanllenas joanllenas released this 14 Mar 18:17
· 23 commits to master since this release
0b7a631

Migration

  • If you come from v5.0.0 you probably don't have to do anything.
  • If you come from v3.1.0 it's recommended to first install v5.0.0, which is a transitional release that marks old APIs as deprecated. After migrating all deprecations you can safely install v6.

In this release

  • Added chain() API. (docs)

Breaking changes

  • Removed all APIs that were marked as deprecated and replaced by new ones:
Old API New API
RemoteDataTags -
AnyRemoteData RemoteData<any, any>
NotAsked.of() notAsked()
InProgress.of() inProgress()
Failure.of() failure()
Success.of() success()
InProgress::value() InProgress::value
Failure::value() Failure::value
Failure::error() Failure::error
Success::value() Success::value
  • All RemoteData variants are plain JavaScript objects, so you won't be able to use instanceof to discriminate between them. Use the type guards or folds instead:

Type guards

type User = { email: string };
const myRemoteData: RemoteData<User> = failure('Something went wrong.', {
  email: '[email protected]'
});

// (...)

if (isFailure(myRemoteData)) {
  // Here myRemoteData is narrowed to Failure
  console.log(`This is the failure: ${myRemoteData.error}`);
  console.log(`I have some data: ${myRemoteData.value.email}`);
}

Fold

const rd = success('this is fine!');
const result = fold(
  () => 'not asked',
  val => 'in progress: ' + val,
  (error, value) => `failure: ${error} ${value}`,
  value => 'success: ' + value,
  rd
);
console.log(result); // success: this is fine!
  • If you were using the custom localStorageSyncReducer reducer to persist / rehydrate the store now it is not needed anymore, you can use the library without any hacks. Check the ngrx example in the demo app.