@uirouter/rx

WebJar for @uirouter/rx

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

uirouter__rx
Last Version

Last Version

0.3.1
Release Date

Release Date

Type

Type

jar
Description

Description

@uirouter/rx
WebJar for @uirouter/rx
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/ui-router/rx

Download uirouter__rx

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/uirouter__rx/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>uirouter__rx</artifactId>
    <version>0.3.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/uirouter__rx/
implementation 'org.webjars.npm:uirouter__rx:0.3.1'
// https://jarcasting.com/artifacts/org.webjars.npm/uirouter__rx/
implementation ("org.webjars.npm:uirouter__rx:0.3.1")
'org.webjars.npm:uirouter__rx:jar:0.3.1'
<dependency org="org.webjars.npm" name="uirouter__rx" rev="0.3.1">
  <artifact name="uirouter__rx" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='uirouter__rx', version='0.3.1')
)
libraryDependencies += "org.webjars.npm" % "uirouter__rx" % "0.3.1"
[org.webjars.npm/uirouter__rx "0.3.1"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

@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();
org.webjars.npm

UI-Router

State-based routing for single page web applications

Versions

Version
0.3.1