kuy / redux-tower

Saga powered routing engine for Redux app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Additional saga for purpose like onLeave

kuy opened this issue · comments

const routes = {
  'posts/new': [function* enter() {
    // onEnter
  }, function* leave() {
    // onLeave
  }],
};

Working with nested routes.

const routes = {
  '/admin': {
    [ENTER]: function* auth() {
      // Authentication
    },
    '/dashboard': Dashboard,
    '/posts': {
      [ENTER]: ...,
      '/new': PostsNew,
    },
    [LEAVE]: ...
  }
};

OR

const routes = {
  '/admin': [function* enter() {
    // Authentication
  }, {
    '/dashboard': Dashboard,
    '/posts': {
      [ENTER]: ...,
      '/new': PostsNew,
  }, function* leave() {
    // Cleanup
  }]
};