Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement request: use generics with IndividualConfig #878

Open
yl-endress opened this issue Apr 7, 2021 · 1 comment
Open

Enhancement request: use generics with IndividualConfig #878

yl-endress opened this issue Apr 7, 2021 · 1 comment

Comments

@yl-endress
Copy link

yl-endress commented Apr 7, 2021

Hey guys,

thank you for this awesome work!

Currently, we need a custom toast with custom event handlers... So far i found here an approach: https://medium.com/@chen.reuven/ngx-toastr-with-custom-buttons-a23b90ab5a08 (here the mentioned sample: https://stackblitz.com/edit/ngx-custom-toastr-dynamic-buttons?embed=1&file=app/app.component.ts).

To my question: What do you think about using the IndividualConfig as a generic?

export declare class Toast<IC extends IndividualConfig = IndividualConfig> implements OnDestroy {
...
    options: IC;
...
}

In the stackblitz sample

    this.toastRef = this.toastr
      .show<MyCustomConfig>("Test", null, {
....
        // @ts-ignore <- wouldn't be needed
        buttons: this.toastButtons
      })
      .onAction.subscribe(x => {
        alert(`${x.title} is pressed`);
        console.log(x);
      });

the ts-ignore wouldn't be needed (app.component.ts line 36) and we would be able to add custom properties, too! Also, the origin functionality should work like this.

Cause of the default genneric assignment, the current behavior wouldn't be touched => following is still possible:

    this.toastr.show(...)
@yl-endress yl-endress changed the title Enhancement request: use generics in IndividualConfig Enhancement request: use generics with IndividualConfig Apr 7, 2021
@scttcper
Copy link
Owner

scttcper commented Apr 7, 2021

if you're willing to make a pr, open to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants