New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

riot-history-manager

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

riot-history-manager

```npm install riot-history-manager```

3.3.4
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

riot wrapper for history-manager

Installation

npm install riot-history-manager

Usage

index.js

import "riot-history-manager";

// any code here

main.riot

<main>
    <router>
        <route path="" redirect="home" />
        <route path="home">
            <span>HOME</span>
        </route>
        <route path="page1">
            <span>PAGE 1</span>
            <img src="img.jpg" need-loading>
        </route>
    </router>

    <script>
        import { Router } from "history-manager";

        Router.setContext({
            // ...
        });
        Router.setContext({
            // ...
        });

        export default {
            onMounted() {
                Router.start()
            }
        }
    </script>
</main>

Routing cycle

As soon as the Router calls the route component listener, the latter mounts the slot in a child div element.

In this stage there is the mount cycle of riot.

Just after this the div element is set with display: none until the loading is complete, so you should consider this in any operation started in the mount cycle.

Now is dispatched the "beforeroute" event in every newly created element.

The route now is waiting all the need-loading elements to fire the "load" event.

When all they are done, it will dispatch the "unroute" event to the previous route - if any - and then unmounted it.

Now the div element containing the slot is set with display: block and is dispatched the event "route".

Following a more concise explanation:

  • currentRoute.mount()
  • display: none
  • currentRoute.dispatchToChildren("beforeroute")
  • waiting "load" from need-loading elements
  • previousRoute.dispatchToChildren("unroute")
  • previousRoute.unmount()
  • display: block
  • currentRoute.dispatchToChildren("route")

FAQs

Package last updated on 14 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts