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 })
This allows us to make our adding of items uniform. How?
At first, this won't cause an issue:
However, it gets problematic in the long term, and given the fact that we're prone to human error, like so:
To solve this, we'll use constants, like so:
For this to work, we'll now start to require a short boilerplate for the library to work.
However, any undefined string passed to
typewill now cause the function to throw an error:You'll have to create an
all(or whatever name) type for this work: