routing

Source routing

The routing library is a small routing library that handles top level DApp navigation. To be small as possible, it uses the navigo routing as helper library.


goToOnboarding

routing.goToOnboarding();

Go to onboarding. (#/onboarding.evan)


goToDashboard

routing.goToDashboard(arguments);

Go to dashboard. (#/dashboard.evan)


isOnboarding

routing.isOnboarding(arguments);

Determines if the user is on the onboarding page.

Returns

boolean : True if onboarding, False otherwise. (when url includes /onboarding.domainName)


getActiveRootENS

routing.getActiveRootENS();

Gets the active root ens.

Returns

string: The active root ens.

Example

// http://localhost:3000/index.html#/dashboard.evan/favorites.evan
routing.getActiveRootENS()
// result: dashboard.evan

getDefaultDAppENS

routing.getDefaultDAppENS();

Gets the default root DApp ens (mapped to the *.evan.network prefix). Default is dasboard.evan.

Returns

Promise returns string: default DApp ens path

Example

routing.getDefaultDAppENS()

http://localhost:3000/index.html => dashboard.evan http://taskboard.evan.network/index.html => taskboard.evan http://customer.evan.network/index.html => customer.evan


beforeRoute

routing.beforeRoute();

Prerouting checks to handle if the user was logged in and onboared. Navigates to onboarding / default dapp ens when necessary.

Returns

Promise returns void: resolved when done


onRouteChange

routing.onRouteChange();

Function to check if the route DApp hash changed => run beforeRoute and set the route active. Start DApp when root DApp changed

Returns

Promise returns void: resolved when done


initialize

routing.initialize();

Initialize the whole routing mechanism. Starts navigo, and runs initial route change for default route detection and dapp loading.

Returns

Promise returns void: resolved when done


getRouteFromUrl

routing.getRouteFromUrl();

Takes the current url, removes #, /#, #/ and returns the original hash value without query params.

Returns

string: transforms #/dapp/dapp1?param1=est to dapp/dapps


history

routing.history.push('dashboard.evan/favorites.evan');

The current navigation stack and includes every route that is opened from apps to handle a specific and logical go back function. Each application should implement an navigate function that pushes into this history array.

Important: Need to be filled by the application it self!!!


updateHistory

routing.updateHistory();

Takes the current navigation history and writes it to the sessionStorage if the user navigates to another page and navigates back