Socket
Book a DemoInstallSign in
Socket

ip-stencil-route-listener

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ip-stencil-route-listener

A simple listener around Stencil router.

2.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

IP Stencil Route Listener

Built With Stencil

A simple listener around Stencil router.

Installing

Script tag

  • Put a script tag similar to this <script src='https://unpkg.com/ip-stencil-route-listener@2.0.0/dist/ip-stencil-route-listener.js'></script> in the head of your index.html

In a stencil-starter app

  • Run npm install ip-stencil-route-listener --save
  • Add an import to the npm packages import 'ip-stencil-route-listener';

Using Example

Check out this demo

  @State()
  pageState: string[] = [];

  @Listen('pageEnter')
  onPageEnter(e: CustomEvent<LocationSegments>) {
    this.pageState = [...this.pageState, `Page enter ${e.detail.pathname}`];
  }

  @Listen('pageLeave')
  onPageLeave(e: CustomEvent<LocationSegments>) {
    this.pageState = [...this.pageState, `Page leave ${e.detail.pathname}`];
  }

  render() {
    return (
      <main>
        <stencil-router>
          <stencil-route-switch scrollTopOffset={0}>
            <stencil-route
              url="/"
              component="ip-app-home"
              exact={true}
              // The Magic happens here
              routeRender={props => <ip-stencil-route-listener props={props} />}
            />
            <stencil-route
              url="/about"
              exact={true}
              component="ip-app-about"
              // The Magic happens here
              routeRender={props => <ip-stencil-route-listener props={props} />}
            />
          </stencil-route-switch>
        </stencil-router>
        <ul>
          {this.pageState.map(page => (
            <li>{page}</li>
          ))}
        </ul>
      </main>
    );
  }

FAQs

Package last updated on 22 Apr 2020

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.