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

Adding message with type by constants #4

Open
srph opened this issue Apr 17, 2015 · 0 comments
Open

Adding message with type by constants #4

srph opened this issue Apr 17, 2015 · 0 comments

Comments

@srph
Copy link
Member

srph commented Apr 17, 2015

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 })
@srph srph changed the title Adding message based on constants Adding message with type by constants Apr 17, 2015
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

1 participant