1.0.8 • Published 7 years ago

ezy-routing v1.0.8

Weekly downloads
28
License
-
Repository
-
Last release
7 years ago

EZY ROUTING

Ezy routing is routing library for creating single page web applications. 

How to Use?

Download

npm install ezy-routing --save-dev

Include

<script src="path/to/routing.min.js"></script>

Usage

<script>
    EzyRouting.init({
        pageNotFound:function(){
            //Do Something here
        },
        routes:[
            {url:'', action:function(){}},
            {url:'about',action:function(){}}
        ]
    });
</script

Options

pageNotFound*

  • Value - Function

  • Description: This function will be triggered when route doesn't match.

loader

  • Value - Function

  • Description: When route is changed in the URL this function will be triggered.

before

  • Value - Function

  • Description: After loader is initiated this function will be triggered and this function should return a PROMISE object. On success of promise object route action will be triggered

routes*

url*
  • Value - String

  • Description: Need to specify the route URL

Examples
  1. 'about'
  2. 'product/create'
  3. 'product/:id' - ':id' is dynamic value and it is mandatory
  4. 'product/:id?' - ':id' is dynamic value and it is optional. this url will match for 'product/' and 'product/123'
data
  • Value - Any value

  • Description: Pass some data from route object to the action during runtime. Example if you are using same action/function in multiple route to differentiate you can pass data.

action
  • Value - Function

  • Parameter - Object contains 'data' and 'params'. Here 'data' is data value passed from route and 'params' will have the dynamic value in the route URL

    		Route: {url:'product/:id', data:"Product View screen", action:....}
    	
    		Parameter for the URL 'product/123': {data:"Product View screen", params:{id:123}}
  • Description: Once route matches this function will be executed Note: If before is specified then promise object should get resolved to execute action

redirectTo
  • Value - String

  • Description: Need to specify the redirect URL of some other route. External Link redirect will not happen. Note: Either redirectTo or action is mandatory

children
  • Value - Array

  • Description: Need to specify the child routes in this field, which accepts array of routes

Note:

It is tested in Chrome and Firefox. Need to fix issues in Internet Explorer

License: Open Source
1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago