Giter VIP home page Giter VIP logo

abstract-state-router's Introduction

ChangelogJoin the chat on DiscordAPI documentation

Brief explanation

abstract-state-router lets you build single-page webapps using nested routes/states. Your code doesn't reference routes directly, like /app/users/josh, but by name and properties, like app.user + { name: 'josh' }.

To find out why you should be using this kind of router, read Why Your Webapp Needs a State-Based Router.

abstract-state-router is heavily inspired by the original ui-router. The biggest difference is: you can use abstract-state-router with whatever templating/component library you like.

It is similar in that way to the new ui-router, except that abstract-state-router is smaller, its documentation is more readable, and it is easier to create new renderers for arbitrary view libraries.

To see an example app implemented with a couple of different browser rendering libraries, click here to visit the state-router-example on Github Pages.

Project status

This project is stable and has been used in production for years.

The last major version bump change was in July of 2021 when the project started shipping modern JS instead of ES5. There have been no breaking changes to the library's function APIs since 2015.

abstract-state-router is extensible without much work, so very few feature additions have been necessary.

I occasionally have dreams of a rewrite, but it's hard to justify when the current version works so well for my main target use case (business software).

Browser compatibility

This project is currently published as CommonJS with modern JS syntax. If you're targeting browsers more than 2-3 years old, I assume you're already compiling your code for your target environments.

If you're supporting really old browsers pre-ES2015 browsers, you'll need polyfills for Promise and Object.assign. Check out polyfill.io for automatic polyfills, it makes life super-easy.

Current renderer implementations

If you want to use the state router with any other templating/dom manipulation library, read these docs! It's not too bad to get started.

Install

npm i abstract-state-router

Your CommonJS-supporting bundler should be able to import make_state_router from 'abstract-state-router' without issue.

API

Instantiate

var createStateRouter = require('abstract-state-router')

var stateRouter = createStateRouter(makeRenderer, rootElement, options)

The makeRenderer should be a function that returns an object with these properties: render, destroy, and getChildElement. Documentation is here - see test/support/renderer-mock.js for an example implementation.

The rootElement is the element where the first-generation states will be created.

options

Possible properties of the options object are:

  • pathPrefix defaults to '#'. If you're using HTML5 routing/pushState, you'll most likely want to set this to an empty string.
  • router defaults to an instance of a hash brown [email protected]. The abstract-state-router unit tests use the hash brown router stub. To use pushState, pass in a hash brown router created with sausage-router.
  • throwOnError defaults to true, because you get way better stack traces in Chrome when you throw than if you console.log(err) or emit 'error' events. The unit tests disable this.

stateRouter.addState({name, route, defaultChild, data, template, resolve, activate, querystringParameters, defaultParameters, canLeaveState})

The addState function takes a single object of options. All of them are optional, unless stated otherwise.

name is parsed in the same way as ui-router's dot notation, so 'contacts.list' is a child state of 'contacts'. Required.

route is an express-style url string that is parsed with a fork of path-to-regexp. If the state is a child state, this route string will be concatenated to the route string of its parent (e.g. if 'contacts' state has route ':user/contacts' and 'contacts.list' has a route of '/list', you could visit the child state by browsing to '/tehshrike/contacts/list').

defaultChild is a string (or a function that returns a string) of the default child's name. Use the short name (list), not the fully qualified name with all its parents (contacts.list).

If the viewer navigates to a state that has a default child, the router will redirect to the default child. (For example, if 'list' is the default child of 'contacts', state.go('contacts') will actually be equivalent to state.go('contacts.list'). Likewise, browsing to '/tehshrike/contacts' would take the viewer to '/tehshrike/contacts/list'.)

data is an object that can hold whatever you want - it will be passed in to the resolve and activate functions.

template is a template string/object/whatever to be interpreted by the render function. Required.

resolve is a function called when the selected state begins to be transitioned to, allowing you to accomplish the same objective as you would with ui-router's resolve.

activate is a function called when the state is made active - the equivalent of the AngularJS controller to the ui-router.

querystringParameters is an array of query string parameters that will be watched by this state.

defaultParameters is an object whose properties should correspond to parameters defined in the querystringParameters option or the route parameters. Whatever values you supply here will be used as the defaults in case the url does not contain any value for that parameter. If you pass a function for a default parameter, the return of that function will be used as the default value.

For backwards compatibility reasons, defaultQuerystringParameters will work as well (though it does not function any differently).

canLeaveState is an optional function with the state's domApi as its sole argument. If it returns false, navigation from the state will be prevented. If it is returns true or is left undefined, state changes will not be prevented.

resolve(data, parameters, callback(err, content).redirect(stateName, [stateParameters]))

data is the data object you passed to the addState call. parameters is an object containing the parameters that were parsed out of the route and the query string.

Returning values

Your resolve function can either return a promise, or call the callback.

Properties on the returned object will be set as attributes on the state's component.

async function resolve(data, parameters) {
	const [ user, invoice ] = await Promise.all([
		fetchUser(parameters.userId),
		fetchInvoice(parameters.invoiceId),
	])

	return {
		user,
		invoice,
	}
}

Errors/redirecting

If you return a rejected promise or call callback(err, content) with a truthy err value, the state change will be cancelled and the previous state will remain active.

If you call callback.redirect(stateName, [stateParameters]), the state router will begin transitioning to that state instead. The current destination will never become active, and will not show up in the browser history.

To cause a redirect with promises, return a rejected promise with an object containing a redirectTo property with name and params values for the state to redirect to:

function resolve(data, parameters) {
	return Promise.reject({
		redirectTo: {
			name: 'otherCoolState',
			params: {
				extraCool: true
			}
		}
	})
}

activate(context)

The activate function is called when the state becomes active. It is passed an event emitter named context with four properties:

  • domApi: the DOM API returned by the renderer
  • data: the data object given to the addState call
  • parameters: the route/querystring parameters
  • content: the object passed into the resolveFunction's callback

The context object is also an event emitter that emits a 'destroy' event when the state is being transitioned away from. You should listen to this event to clean up any workers that may be ongoing.

addState examples

stateRouter.addState({
	name: 'app',
	data: {},
	route: '/app',
	template: '',
	defaultChild: 'tab1',
	async resolve(data, parameters) {
		return isLoggedIn()
	},
	activate(context) {
		// Normally, you would set data in your favorite view library
		var isLoggedIn = context.content
		var ele = document.getElementById('status')
		ele.innerText = isLoggedIn ? 'Logged In!' : 'Logged Out!'
	}
})

stateRouter.addState({
	name: 'app.tab1',
	data: {},
	route: '/tab_1',
	template: '',
	async resolve(data, parameters) {
		return getTab1Data()
	},
	activate(context) {
		document.getElementById('tab').innerText = context.content

		var intervalId = setInterval(function() {
			document.getElementById('tab').innerText = 'MORE CONTENT!'
		}, 1000)

		context.on('destroy', function() {
			clearInterval(intervalId)
		})
	}
})

stateRouter.addState({
	name: 'app.tab2',
	data: {},
	route: '/tab_2',
	template: '',
	async resolve(data, parameters) {
		return getTab2Data()
	},
	activate(context) {
		document.getElementById('tab').innerText = context.content
	}
})

stateRouter.go(stateName, [stateParameters, [options]])

Browses to the given state, with the current parameters. Changes the url to match.

The options object currently supports two options:

  • replace - if it is truthy, the current state is replaced in the url history.
  • inherit - if true, querystring parameters are inherited from the current state. Defaults to false.

If a state change is triggered during a state transition, and the DOM hasn't been manipulated yet, then the current state change is discarded, and the new one replaces it. Otherwise, it is queued and applied once the current state change is done.

If stateName is null, the current state is used as the destination.

stateRouter.go('app')
// This actually redirects to app.tab1, because the app state has the default child: 'tab1'

stateRouter.evaluateCurrentRoute(fallbackStateName, [fallbackStateParameters])

You'll want to call this once you've added all your initial states. It causes the current path to be evaluated, and will activate the current state. If no route is set, abstract-state-router will change the url to to the fallback state.

stateRouter.evaluateCurrentRoute('app.home')

stateRouter.stateIsActive([stateName, [stateParameters]])

Returns true if stateName is the current active state, or an ancestor of the current active state...

...And all of the properties of stateParameters match the current state parameter values.

You can pass in null as the state name to see if the current state is active with a given set of parameters.

// Current state name: app.tab1
// Current parameters: { fancy: 'yes', thing: 'hello' }
stateRouter.stateIsActive('app.tab1', { fancy: 'yes' }) // => true
stateRouter.stateIsActive('app.tab1', { fancy: 'no' }) // => false
stateRouter.stateIsActive('app') // => true
stateRouter.stateIsActive(null, { fancy: 'yes' }) // => true

stateRouter.makePath(stateName, [stateParameters, [options]])

Returns a path to the state, starting with an optional octothorpe #, suitable for inserting straight into the href attribute of a link.

The options object supports one property: inherit - if true, querystring parameters are inherited from the current state. Defaults to false.

If stateName is null, the current state is used.

stateRouter.makePath('app.tab2', { pants: 'no' })

stateRouter.getActiveState()

Returns the last completely loaded state

// Current state name: app.tab1
// Current state params: pants: 'no'
stateRouter.getActiveState() // => { name: 'app.tab1', parameters: { pants: 'no' }}

Events

These are all emitted on the state router object.

State change

  • stateChangeAttempt(functionThatBeginsTheStateChange) - used by the state transition manager, probably not useful to anyone else at the moment
  • stateChangeStart(state, parameters, states) - emitted after the state name and parameters have been validated
  • stateChangeCancelled(err) - emitted if a redirect is issued in a resolve function
  • stateChangeEnd(state, parameters, states) - after all activate functions are called
  • stateChangeError(err) - emitted if an error occurs while trying to navigate to a new state - including if you try to navigate to a state that doesn't exist
  • stateError(err) - emitted if an error occurs in an activation function, or somewhere else that doesn't directly interfere with changing states. Should probably be combined with stateChangeError at some point since they're not that different?
  • routeNotFound(route, parameters) - emitted if the user or some errant code changes the location hash to a route that does not have any states associated with it. If you have a generic "not found" page you want to redirect people to, you can do so like this:
stateRouter.on('routeNotFound', function(route, parameters) {
	stateRouter.go('not-found', {
		route: route,
		parameters: parameters
	})
})

DOM API interactions

  • beforeCreateState({state, content, parameters})
  • afterCreateState({state, domApi, content, parameters})
  • beforeDestroyState({state, domApi})
  • afterDestroyState({state})

Testing/development

To run the unit tests:

  • clone this repository
  • run npm install
  • run npm test

State change flow

  • emit stateChangeStart
  • call all resolve functions
  • resolve functions return
  • NO LONGER AT PREVIOUS STATE
  • destroy the contexts of all "destroy" states
  • destroy appropriate dom elements
  • call render functions for "create"ed states
  • call all activate functions
  • emit stateChangeEnd

Every state change does this to states

  • destroy: states that are no longer active at all. The contexts are destroyed, and the DOM elements are destroyed.
  • create: states that weren't active at all before. The DOM elements are rendered, and resolve/activate are called.

HTML5/pushState routing

pushState routing is technically supported. To use it, pass in an options object with a router hash-brown-router constructed with a sausage-router, and then set the pathPrefix option to an empty string.

var makeStateRouter = require('abstract-state-router')
var sausage = require('sausage-router')
var makeRouter = require('hash-brown-router')

var stateRouter = makeStateRouter(makeRenderer, rootElement, {
	pathPrefix: '',
	router: makeRouter(sausage())
})

However to use it in the real world, there are two things you probably want to do:

Intercept link clicks

To get all the benefits of navigating around nested states, you'll need to intercept every click on a link and block the link navigation, calling go(path) on the sausage-router instead.

You would need to add these click handlers whenever a state change happened.

Server-side rendering

You would also need to be able to render the correct HTML on the server-side.

For this to even be possible, your chosen rendering library needs to be able to work on the server-side to generate static HTML. I know at least Ractive.js and Riot support this.

The abstract-state-router would need to be changed to supply the list of nested DOM API objects for your chosen renderer.

Then to generate the static HTML for the current route, you would create an abstract-state-router, tell it to navigate to that route, collect all the nested DOM API objects, render them as HTML strings, embedding the children inside of the parents.

You would probably also want to send the client the data that was returned by the resolve functions, so that when the JavaScript app code started running the abstract-state-router on the client-side, it wouldn't hit the server to fetch all the data that had already been fetched on the server to generate the original HTML.

Who's adding this?

Track development progress in #48.

It could be added by me, but probably not in the near future, since I will mostly be using this for form-heavy business apps where generating static HTML isn't any benefit.

If I use the abstract-state-router on an app where I want to support clients without JS, then I'll start working through those tasks in the issue above.

If anyone else has need of this functionality and wants to get keep making progress on it, I'd be happy to help. Stop by the chat room to ask any questions.

Maintainers

License

WTFPL

abstract-state-router's People

Contributors

artskydj avatar crissdev avatar daytonlowell avatar dependabot[bot] avatar greenkeeperio-bot avatar gudahtt avatar m59peacemaker avatar mtn-view avatar saibotsivad avatar subpx avatar tehshrike avatar walfie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

abstract-state-router's Issues

A dot/period(.) in url for a named parameter returns an error

When adding a state that includes a named parameter eg /user/:userId, if the named parameter portion of the url includes a dot (eg. /user/123.345) you get the error Cannot GET <path> (see screenshot)

Route code

stateRouter.addState({
    name: 'app.user',
    route: 'user/:userId',
    template: User,
    resolve: (data, parameters, cb) => {
      const {userId} = parameters;
      cb(undefined, { userId });
    }
  });

Result

Screen Shot 2019-04-17 at 9 12 41 am

Server-side rendering

  • ability to load resolve data from a global instead of fetching the data remotely (pull request #49)
  • ability to get the resolve data from a state transition
  • another module to wrap renderers and collect the domApis
  • another module to add click handlers to every hash link in the dom, that could be easily composed with state change success events
  • document all of the above, replacing the "server-side rendering" section in the readme

Pull requests accomplishing any of the above bits should be opened against the server-side-rendering branch.

Why doesn't it scroll to the top when you navigate between states

As phrased by @daytonlowell:

huh, totally annoying thing I just now noticed. If you're on state A and scroll down the page and then go to state B, you won't be taken back to the top when state B loads.

A reasonable question that needs a reasonable answer written down somewhere (I know I've answered it a couple times before in chats, so it really needs to be documented).

There are other general questions like this that I know need answers, so I'm thinking there should be a new markdown file at the root of the repo named "reasonable-questions.md" or something, and a list of questions linking to the answers in that file at the bottom of readme.md.

Write tests/fix "not found" behavior for evaluateCurrentRoute

Right now evaluateCurrentRoute only checks "is there any route" before sending you to a default state.

It would probably be more correct to check "is the route empty?" and if so, send you to that default state, and if not, emit a notFound event or send you to a 404-not-found page.

Thoughts?

Reloading current route

Is there any way to reload the current route? I know I can just not use event.preventDefault() but that reloads the app as a whole.

Modern JS features

Right now abstract-state-router doesn't require any transforms (beyond CommonJS module resolution) to run in an ES5 environment.

ES2015 spreads and spreads, and at this point I feel like most people using abstract-state-router are probably already transpiling to ES5 if they want to support IE11 or older. Certainly anyone using Webpack is, and anyone using Browserify would continue having no problem, as long as the appropriate transforms were added to the package.json.

What could/should be done during such an upgrade? Things that come to mind are

  1. drop the Promise polyfill
  2. upgrade to new language features like const and arrow functions and object destructuring
  3. change the resolve function to take an arguments object instead of two ordered arguments before the callback (probably should have been that way already)
  4. support promises more explicitly? I'm not sure if anything there's actually anything left to do to make the library fully Promise-friendly

Non-async resolve results in confusing behavior

I put some test data in the resolve, and forgot to set it as an async function. When I try to load a route, I don't get any error message or anything. It just appears to get stuck.

resolve: () => {
    const thing = {
        test_data: true
    }
    return thing
}

I would have expected it to either work as-is, or to throw an error about a missing .then method.

Request about state router

Hi,

As a hobbiest i am writing a custom app for myself that i want alot of things to do. Ui router in Angular is fine and all but i want a custom one because i dont like angular and its move to 2.0.

I want to know what your Ui-router comes out of the box off and if you could give me some help in setting this up for my project

  1. for SEO is hash tag actually good and does your state router support good practice for routes
  2. is my attached img file possible with your state router (see attachment for my desired router)
  3. is if possible to pass fucntions /data to a certain view by use of the state router through for example the use of a directive or controller

in the attached image i showed you what in projects what i want to develop see as the most commen thing to do for apps yet i was anable to find it if i was good in JS i would be able to pull it off. Thats why im so dependant on good libraries or framework. I do believe though that if you look at my request it can benefit your state router for helping designers like me who arent coders at heart to build a View

regardless of that hats off on making and contributing so much to the open source community

kind regards

Gavarni
state router request

Emit events on state create/change/remove

Whenever a state is created, changed (template reset), or destroyed, an event should be fired.

The original state and the domApi should be emitted.

The new events should be documented. We'll need a new documentation section it looks like - stateChangeStart and stateChangeEnd and stateChangeError should be noted too.

It is possible for `makePath` to return a url that will not be matched by the router

Discovered by @Vehmloewff

If you have a parent state with a route parent and a default child state that has an empty string as its route, makePath will return a route /parent but the router will only be listening for a route with a trailing slash /parent/.

Should probably start with a unit test asserting that the output of both those functions match each other.

I'm just guessing, but the best fix might be to change page-path-builder (used in makePath only) to not add a trailing slash when there are empty chunks like that.

Or maybe the root issue is with the arguments being passed to makePath

Proposal to implement empty state

I really need to have fake states in the route just for grouping pages.
Currently, we should implement new state and render page with one uiView tag, it looks too complicated and we should have an extra rending pass. Also, our URL became too long.
How I want, example:
A.B.C.D - /a/b/d
A.B.C.E - /a/b/e
but if we will check state to highlight an item in menu A.B.C will be 'active' for both path. C here is the empty state, just for grouping. For .E and .D uiView tag will be from A.B state.
In this case, we still have one path for one state but now possible to use different levels in URL and in the state.

In vue-router some part of similar problem solved by named-views - https://router.vuejs.org/en/essentials/named-views.html
and other by alias.

Default values for route parameters

You should be able to set default parameters that will get applied to the route parameters if you do stateRouter.go('someState') or if a default child state is loaded.

defaultQuerystringParameters may already be applied to route parameters, in which case its name (and the documentation) should be updated.

Push state routing not working with "defaultChild state with an empty route string"

As per title, I cannot get the following scenario to work.

stateRouter.addState({
    name: "app.foo",
    route: "/foo/",
    template: {},
    defaultChild: "view"
})
stateRouter.addState({
    name: "app.foo.view",
    route: "",
    template: {},
})
stateRouter.addState({
    name: "app.foo.edit",
    route: "edit",
    template: {},
})

When I am on a page that has a link asr.go("app.foo"), the url correctly shows as /foo/, but the browser goes to /foo, and nothing renders. If I manually change the url to /foo/, it renders. I have tried removing the / from app.foo, and tried adding it to app.foo.view too.

The edit state works in all instances. Changing the route for app.foo.view to eg view works too.

I am using svelte-state-renderer with embedded components, but I do no think this is the issue, because your demo implementation handles this scenario successfully (without push state routing). So I think the problem must be in ASR.

No way for children to depend on route parameters of ancestors

If a parent state has a route with a non-querystring-parameter (e.g. /parent/:importantId), there is no way for child states to indicate that they depend on that parameter. The querystringParameters array is only used to check actual querystring parameters - there's no way for the child to indicate that it needs to reset when importantId changes.

Ignore parameters that are not used by any state

This is one of my diversions from ui-router behavior that I regret.

Right now, you can pass whatever parameters into stateRouter.go or stateRouter.makePath and they will get put into the url and show up on the parameters object, even if no state depends on them.

I think that if you attempt to create a route, or if you try to navigate to a route, and you use any parameters that are not used by any of the states at the route you're going to, then those parameters should just be dropped and shouldn't show up in the url.

This could be accomplished with only a feature bump if a new option was added to stateRouter initialization, something like allowParametersNotUsedByAnyState or whatever. It could default to true (the current behavior).

Eventually, we could log a deprecation warning when that value was true, and eventually eventually we could flip the default to false.

Any thoughts?

Lazy-loading states

On Twitter, Ryan Grove brought up the need to painlessly lazy-load route modules.

On the surface, this seems like it would be easy to implement. The state's template property could be a promise-returning function that would return the real template object. Exactly how the function would go out and get the template/code would be an implementation detail that would depend on the bundler the consumer was using.

In practice, I don't feel comfortable writing out specs until I know of at least one (probably Webpack) user willing to give some real use case details here so that I could be sure that the solution I've thought of would solve a real problem.

So, if you're some Webpack user (or anyone else with a lazy-load-friendly bundler that you want to use) and you want this feature, let me know here! I'm willing to implement it if the complexity doesn't get out of hand.

onActivate and onDestroy events

Even more events that I need!

These should emit right after the activate function is called on a state, and right before the destroy event is fired.

Also I apparently forgot to document all the events with #54 so I should do that now.

Adding "inherit" option to stateRouter.go

I ran into a case where I wanted ui-router's inherit option on a stateRouter.go call.

The option inherit: true should cause any properties on the current route to be carried over to whatever route you are generating a link to.

Unlike in ui-router, it should default to false.

Adding multiple keyed templates for a state

Is the following possible? And if not, how would I go about implementing this? I'm open to putting out a PR but am having trouble understanding the codebase.

addState({
   // everything else
  templates: { // normally just one template
    default: componentFn,
    nav: navComponentFn,
  },
})
<uiView name="nav" />
<uiView />

State name should be optional to `state.go`

If the first argument to state.go is not a string, then it should behave as if you had passed in the name of the current state.

Discussion point: should the "current state" be the last state that the router started transitioning to, or should it be the last state that was fully loaded?

Put another way, if you call redirect({ someParameter: 'some other option' }) inside a resolve function, should it redirect you to the state that was in the middle of being loaded, or the state before that?

I'm leaning towards the state that you're in the middle of transitioning to, but I'm open to other arguments.

Possible to send actual objects via callback.redirect?

My app is using push state routing. In my resolve functions, I am doing some checks before returning a successful callback. For example, you visit book/50, and I do a check to ensure that book 50 exists, the user has permission, etc. If there is a problem, I am doing a callback.redirect() to an error page, and sending an error object in the parameters. However, the object doesn't make it intact to the error state's resolve function, as it gets turned into a parameter on the query line. Is there a way to pass the actual error object to the error state's resolve function?

Get browserstack tests passing again

Thanks to some help from another dev, browserstack tests report their results much more reliably now. I've updated package.json to use the better versions. a3a62f8

It looks like some tests aren't passing any more, most notably the webpack test that tries to read from disc. We should have some difference between node tests and browser tests so that that test doesn't get loaded.

I'm not sure why some of those other tests aren't passing (I saw one about console.error not being a function in Chrome, which it totally is). It would probably be easier to make sure everything passes with tape-run first.

evaluateCurrentRoute does not work with defaultChild

  1. app state has the defaultChild: default-child-state
  2. app state has a template
  3. call stateRouter.evaluateCurrentState('app') on an invalid route
  4. white screen of death
  5. call stateRouter.evaluateCurrentState('app.default-child-state') on an invalid path, and app.default-child-state is loaded

addState options should be well defined

It's not clear from the documentation which addState() options are required.

As far as I know, these are required: name, template, activate and these are not: route, defaultChild, data, resolve, querystringParameters

This should be documented. (Or fixed if this is not the desired case.)

Should an error be thrown when attempting to add a state without all of the required parameters?

Curious bug here - Navigating between the same route does not cause reactivation

Great initiative but i noticed a bug.
I have a route route: '/:entity/new'
When i navigate to /one_entity/new, the associated state is activated and rendered.
Then i navigate to /another_entity/new, the associated state is not reactivated since its the same route.
Hence the view (riot tag in my case) does not get updated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.