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

ion-modal-launcher

v1.0.1

Published

Ionic 4 component that subscribe to a list of observables and display an ion-modal when each observable emits a value.

Downloads

8

Readme

ion-modal-launcher

Ionic 4 component that subscribe to a list of observables and display an ion-modal when each observable emits a value.

It can be used to trigger modals from different observables, very useful if you need to display a modal from a service or a route guard for example (or anything injected at root).

Install

Run:

npm install ion-modal-launcher --save 

Import IonFormErrorMessagesModule app.module.ts:

import ...
...
import { IonModalLauncherModule } from 'ion-modal-launcher';

@NgModule({
    imports: [
        CommonModule,
        CoreModule,
        ReactiveFormsModule,
        IonicModule,
        ... ,
        IonModalLauncherModule
    ],
    ...
})
export class AppModule {}

You could import in another module too, but I find it better to have only one instance of it at app.component.

Usage

template

I recommend using it at you app.component.html file like the example bellow:

<ion-app>
    <ion-split-pane contentId="main-content">
        ...
        <ion-modal-launcher [observables]="modalObservables">
        </ion-modal-launcher>
    </ion-split-pane>
</ion-app>

obsevables parameter

This parameter is an array of Observable<ModalLauncherOptions>.

ModalLaucherOptions have two properties:

  • modalOptions:
    • ModalOptions from '@ionic/core/dist/types/components/modal/modal-interface'
    • Same options as you pass to ionModalController.creat(options).
    • More information here: https://ionicframework.com/docs/api/modal
  • callback:
    • function that is called when modal is dismissed
    • it have one details parameter that is the result of Ionic modal.dismiss(data), this data param will be available at the callback as details.data.
    • The details parameter type is OverlayEventDetail from @ionic/core

Example for displaying a login modal:

const loginObservable = this.authentication.forbidden.pipe(
    map(url => {
        return {
            modalOptions: {
                component: LoginModalComponent
            },
            callback: details => {
                if (details?.data?.authenticated && url) {
                    this.router.navigate([url]);
                }
            }
        };
    })
);

this.modalObservables = [loginObservable];

I've been using it for a similar case as the above, the authentication guard triggers an next value on the this.authentication.forbidden observable and this displays the login modal as we didn't want the page redirection behavior the login screen on this specific app.

It can be used to trigger modals from any kind of observable, very useful if you need to display a modal from a service or a route guard for example, you add an observable on your service, pass it to the ion-modal-launcher through app.componet as the example above.

Todo

Make the calback part of the rxjs pipeline instead of it being a parameter