1.2.0-alpha.8 • Published 6 years ago

fluxapp-router v1.2.0-alpha.8

Weekly downloads
4
License
MIT
Repository
github
Last release
6 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

6 years ago

1.2.0-alpha.7

6 years ago

1.2.0-alpha.6

7 years ago

1.2.0-alpha.5

7 years ago

1.2.0-alpha.4

7 years ago

1.2.0-alpha.3

7 years ago

1.2.0-alpha.2

7 years ago

1.2.0-alpha.1

7 years ago

1.2.0-alpha

7 years ago

1.1.6

9 years ago

1.1.5

9 years ago

1.1.4

9 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.0

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.9.7

9 years ago

0.9.6

9 years ago

0.9.5

9 years ago

0.9.4

9 years ago

0.9.3

9 years ago

0.9.2

9 years ago

0.9.1

9 years ago

0.9.0

9 years ago

0.8.7

9 years ago

0.8.6

9 years ago

0.8.5

9 years ago

0.8.4

9 years ago

0.8.3

9 years ago

0.8.1

9 years ago

0.8.0

9 years ago