Skip to content

Adding message with type by constants #4

Open
@srph

Description

@srph

This allows us to make our adding of items uniform. How?

At first, this won't cause an issue:

NotifyActions.add({ type: 'notification' })

However, it gets problematic in the long term, and given the fact that we're prone to human error, like so:

// missing i from notification (notificaton)
NotifyActions.add({ type: 'notificaton' })

To solve this, we'll use constants, like so:

NotifyActions.add({ type: SOME_CLASS.NOTIFICATION })

For this to work, we'll now start to require a short boilerplate for the library to work.

AltNotify.config.types('all', 'whatever', 'alerts', 'notification');

However, any undefined string passed to type will now cause the function to throw an error:

// this throws an error
NotifyActions.add({ text: '' });

You'll have to create an all (or whatever name) type for this work:

NotifyActions.add({ type: SOME_CLASS.ALL })

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions