1.2.0-alpha.8 • Published 8 years ago

fluxapp-router v1.2.0-alpha.8

Weekly downloads
4
License
MIT
Repository
github
Last release
8 years ago

fluxapp-router

A router plugin for Fluxapp. Manages the current page state, gives you info about the currently opened page and history, and gracefully degrades on non-historyAPI and non-js browsers.

Installation

npm install --save fluxapp-router

Usage

'use strict';

import fluxApp from 'fluxapp';
import fluxAppRouter from 'fluxapp-router';

fluxApp.registerPlugins({
  router: fluxAppRouter,
});

Router binds to special static methods on components:

willTransitionTo
willTransitionFrom

which enables the components to do some setup at transitions. If false is returned from any of them, the transition will be cancelled.

Actions

Fluxapp router exposes a method on the fluxapp context getRouterActions() but is also available under the namespace router using getActions('router')

go / forward / back

export default React.createClass({
  mixins: [fluxApp.mixins.component],

  statics: {
    willTransitionTo: function() {},
    willTransitionFrom: function() {},
  },

  onBackClick(event) {
    const actions = this.getActions('router');
    const forward = this.state.forward;
    const previous = this.state.previous;
    const options = {};

    if (previous) {
      actions.back();
    } else if (forward) {
      actions.forward();
    } else {
      actions.go('routeid', options);
    }

    event.preventDefault();
  },

})

Components

Link

import Link from 'react-router/components';

<Link to="routerid" meta={customOptions} onClick={customOnCLick} />
<Link to="/route/url" meta={customOptions} onClick={customOnCLick} />

Options

Options provided should be compatible with those used by fluxapps internal router#build method.

1.2.0-alpha.8

8 years ago

1.2.0-alpha.7

8 years ago

1.2.0-alpha.6

8 years ago

1.2.0-alpha.5

8 years ago

1.2.0-alpha.4

8 years ago

1.2.0-alpha.3

8 years ago

1.2.0-alpha.2

8 years ago

1.2.0-alpha.1

8 years ago

1.2.0-alpha

8 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.0

10 years ago

1.0.6

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.9.7

10 years ago

0.9.6

10 years ago

0.9.5

10 years ago

0.9.4

10 years ago

0.9.3

10 years ago

0.9.2

10 years ago

0.9.1

10 years ago

0.9.0

10 years ago

0.8.7

10 years ago

0.8.6

10 years ago

0.8.5

10 years ago

0.8.4

11 years ago

0.8.3

11 years ago

0.8.1

11 years ago

0.8.0

11 years ago