Détail du package

@uirouter/rx

ui-router76.3kMIT1.0.0

Reactive extensions for UI-Router

ui-router, reactive, rxjs

readme

@uirouter/rx

Reactive Extensions (RxJS) for UI-Router

What

This UI-Router plugin exposes various events in UI-Router as RxJS Observables.

  • Transitions (successfull, or any)
  • Parameter values
  • State registration/deregistrations

This helps you to use UI-Router in a reactive mode.

This plugin works with UI-Router Core 2.0 and above (angular-ui-router 1.0.0-rc.1+, ui-router-ng2 1.0.0-beta.4+, ui-router-react 0.4.0+).

Getting

npm install @uirouter/rx

Enabling

This is a UI-Router Plugin. Add the UIRouterRx plugin to your app's UIRouter instance.

import { UIRouterRx } from "@uirouter/rx";

// ... after UI-Router bootstrap, get a reference to the `UIRouter` instance
// ... call `.plugin()` to register the ui-router-rx plugin
uiRouter.plugin(UIRouterRx);

Using

In a state definition,

const foo$ = (uiRouter) => 
    uiRouter.globals.params$.map(params => params.fooId)
      .distinctUntilChanged()
      .map(fooId => fetch('/foo/' + fooId).then(resp => resp.json()))

var fooState = {
  name: 'foo',
  url: '/foo/{fooId}',
  component: FooComponent,
  resolve: [ 
      { token: 'foo$', deps: [ UIRouter ], resolveFn: foo$ } 
  ]
})

In the component, access the foo$ resolve value (it will be an Observable). Subscribe to it and do something with it when it emits a new value.

var subscription = foo$.subscribe(foo => this.foo = foo);

Don't forget to unsubscribe when the component is destroyed.

subscription.unsubscribe();

changelog

1.0.0 (2021-11-30)

Compare @uirouter/rx versions 0.6.5 and 1.0.0

Features

  • rxjs: Add support for RxJS 7 (in addition to 6)

BREAKING CHANGE

  • rxjs semver range changed to ^6.5.3 || ^7.4.0

0.6.5 (2020-01-13)

Compare @uirouter/rx versions 0.6.4 and 0.6.5

0.6.4 (2019-11-19)

Compare @uirouter/rx versions 0.6.0 and 0.6.4

Bug Fixes

  • make RXWAIT custom async policy AOT compatible (a091c48)

0.6.0 (2019-10-01)

Compare @uirouter/rx versions 0.5.0 and 0.6.0

Bug Fixes

  • travis: use service: xvfb instead of launching it manually. install libgconf debian package (eace3a9)

Features

  • add rxwait custom async policy (dca4929)
  • add rxwait custom async policy (ab1aaa4)
  • package: require uirouter/core >=6.0.0 via peerDependency (9bacfa4)

BREAKING CHANGES

  • package: this version of uirouter/rx depends on uirouter/core version 6 and greater Because this package now provides an async resolve policy for Observables, this package now has a peerDependency on uirouter/core version >=6.0.0

0.5.0 (2018-05-08)

Compare @uirouter/rx versions 0.4.5 and 0.5.0

Bug Fixes

  • onError: Handle transition error so rxjs doesn't log rejections (84e6210)

Features

BREAKING CHANGES

  • rxjs 6.0.0 or higher is now required to use this module

0.5.0-alpha.1 (2018-05-07)

Compare @uirouter/rx versions 0.4.5 and 0.5.0-alpha.1

Features

BREAKING CHANGES

  • rxjs 6.0.0 or higher is now required to use this module

0.4.5 (2017-10-17)

Compare @uirouter/rx versions 0.4.4 and 0.4.5

0.4.4 (2017-10-12)

Compare @uirouter/rx versions 0.4.2 and 0.4.4

0.4.2 (2017-10-12)

Compare @uirouter/rx versions 0.4.1 and 0.4.2

0.4.0 (2017-05-08)

  • feat(build): Publish UMD bundles (fd97a1d)
  • feat(plugin): Re-export UIRouterRx as UIRouterRxPlugin (51a31e2)

BREAKING CHANGE

  • rename plugin.name from ui-router-rx to @uirouter/rx

0.3.2 (2017-05-06)

  • chore(*): added .editorconfig file (8101b6b)
  • chore(build): widen dependency on @uirouter/core (ef3ac74)
  • chore(gitignore): re-ignore hidden files (e30ae6e)

0.3.1 (2017-04-22)

  • chore(*): Fix botched npm release

0.3.0 (2017-04-22)

  • chore(*): Rename npm package from ui-router-rx to @uirouter/rx
  • chore(*): Switch dependency from ui-router-core to @uirouter/core

0.2.1 (2017-01-22)

  • fix(*): fix peer dependency for ui-router-core (from ^3.1.1 to >=3.1.1) (4a29191)

0.2.0 (2017-01-20)

0.1.0