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

route-them

v6.0.2

Published

Routing webcomponents to use with lit-bloc-js library

Downloads

6

Readme

<route-them>

This webcomponent follows the open-wc recommendation.

Installation

npm i route-them

Usage

For detailed example, see demo in the git lib:

<script type="module">
  import 'route-them/route-them.js';
</script>

<route-them-controller>
  <!--Place any html code you want-->
  <route-them>
      <a-page route="/">
        <!--Place any html code you want-->
      </a-page>
      <a-page route="/contacts/:id">
        <!--Place any html code you want-->
        <!--id param will be accessible inside this page via RouteThem bloc-->
      </a-page>
  </route-them>
  <!--Place any html code you want-->
</route-them-controller>
  • route-them-controller: Controller which provided route them bloc. Placing controller above gives other components down the tree to navigate using controller block.
  • a-page: A page which will be displayed by this router. The observe the state and get rendered based on that state.
  • route-them: container for pages

To switch routes

let routeBloc = BlocsProvider.of(RouteThemBloc,this);
routeBloc.goToPage("/contacts");

Controlling page behavior with behaves attribute

  1. on a page behaves attribute can be provided, which can have three value: hide | reload
  2. hide all pages will be loaded, but only kept hidden. And reload will remove and reload the page (cleaning up all values inputed , its fresh view altogether), whenever that page is accessed. Default vau eis hide.

Tooling configs

For most of the tools, the configuration is in the package.json to reduce the amount of files in your project.

If you customize the configuration a lot, you can consider moving them to individual files.

Local Demo with web-dev-server

npm start

To run a local development server that serves the basic demo located in demo/index.html

Version info

"version": "5.0.1"

  1. Supports hashed path now, for page routes.

"version": "5.0.0",

  1. Removed lazy hide as it was making no sense. Made reload behavior a true reload behavior.

"version": "4.0.1"

  1. Bug fix: Uncaught DOMException: Failed to execute 'define' on 'CustomElementRegistry': the name "route-them-controller" has already been used with this registry.

"version": "4.0.0"

  1. Need for version 4: Nested route-them where creating a lot of trouble. As both of them use to register window.onpopstate listeners. In an app only one router should be allowed to deal with history, and not every one (which created issues). Therefore from this version on every default router will not control history. Only the one passed save_history:true flag will be saving the history. In case any app tries to register multiple router bloc with this configuration, route-them will throw error. The implications of this is that gtoPage will no more have configuration to save to history functionality, as it will controlled something at construction time of that router.
  2. Now we have new widgets to control app level page routing.
  • app-pages-controller
  • app-pages-container
  • app-page

"version": "3.0.2"

  1. Upgraded bloc-them. facing bugs when route -the are nested with each others.

"version": "3.0.1"

  1. On pop state if null is given then it will return the init state. Bug was because of this.

"version": "3.0.0"

  1. Now all route-them-controller, route-them , and a-page is a 100% width and height;

"version": "2.0.6"

  1. updated as per bloc-them, making overall more generic approach

"version": "2.0.5"

  1. made further small changes to make router more generic and extensible

"version": "2.0.4"

  1. made further small changes to make router more generic.

"version": "2.0.3"

  1. Now you can pass A custom name for page tags to constructor. To create custom conctroller.
export class RouteThem extends BlocBuilder<_BogusBloc,number>{
  constructor(private pageTagName: string = "a-page"){
    super(_BogusBloc, {
      useThisBloc: new _BogusBloc()
    });
  }