npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

future-router

v1.1.2

Published

Intuitive React-Flux Router. It allows reloading a page, backwards and forwards actions and defining routes in a separate module. Signaling a route change is very simple by either including Router.route('name_of_route',{args}) in a href attribute or invok

Downloads

31

Readme

Future Router

Description

Intuitive Router built specifically for React-Flux. It allows reloading a page, backwards and forwards actions and defining routes in a separate module. Signaling a route change is very simple by either including Router.route('name_of_route',{args}) in a href attribute or invoking the action dynamically by doing Router.route(route_name,{args},true).

Usage

The router is built upon the idea of keeping routing information in a separate module from the components and letting the router handle the transistions. The Router can be further factored out into 'sub router if it makes sense to do so'. We personally like having the Router be global but if the complexity of the routes requires locality it can be done easily. In the following code you would export the Router variable instead of assigning in globally.

  1. Define your routes:
    //Router.js
    //Global Router
    global.Router = require('future-router').Router;
    //Define Custom Routes
    Router.Routes = {

      toDumb: function(args){
        //This function can do whatever you want with the specified args which 
        //are a JSON but if you are changing a page we recommend using 
        //these functions
        //Pull in a component, or move this outside if you want a broader scope
        var About = require('./components/About.js');
        //Where the Components will be mounted to, can use another accessor if needed.
        var mount_point = document.getElementById('res');
        //Unmount 
        React.unmountComponentAtNode(mount_point);    
        //Mount new component and send in args as a prop or do processing of args.    
        React.render(<About data={args}/>, mount_point)); 
      },
      //Must exist, This is the primary entry point, you dont necessarily need to do anything here as it will load react normally.
      root: function(args){

      }
    };
  1. Add the init Function to root of app. this is important as this allows reloading and shared links to be rendered correctly. It is important that the Router.init() goes after the render.
    var App = require('./components/app');
    //Dont need to assign to a var if using globally.
    require('./router.js');

    React.render (   
        <App id="app"/>,
      document.getElementById('main')
    );
    Router.init();
  1. Use the Routes in your components:
    var data = {json_stuff: "",more_stuff: ""};
    //In JSX with a href tag(The function returns a string making it easier to create a nice route quickly):
    <a  href={Router.route('route_name',data)}>
    //In an event handler
    handleClick(){
        //the last param signifies that you want the route to be immediately invoked, the function defaults to false to return a string that can be used in a href or something similar
        Router.route('route_name',data,true);
    }
    <button onClick={this.handlerClick}>Click Me</button>

Dependencies

  • jquery
  • React(Optional but designed for it)