Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
@acpaas-ui/js-notification-store
Advanced tools
The Notification Store provides a singleton store to save and easily access notifications throughout your app.
The @acpaas-ui/js-notification-store
package provides a singleton store to save and easily access notifications throughout your app. You can load up a message map and trigger notifications by handle.
On top of that, you can set targets to hold your notifications (e.g. popups, statusbar, forms). Notifications are returned as BehaviorSubjects
, allowing you to subscribe to changes.
NPM
npm install @acpaas-ui/js-notification-store --save
Yarn
yarn add @acpaas-ui/js-notification-store
// ES2015
import { NotificationStore } from '@acpaas-ui/js-notification-store';
const store = new NotificationStore({
404: 'not found'
});
store.triggerNotification('404', 'statusbar');
To load a message map simply provide it in the constructor:
import NotificationStore from 'aui-notification-store';
const store = new NotificationStore({
404: 'not found'
});
If the allowOverrides
option is set to true:
NotificationStore.allowOverrides = true;
you can overwrite the messages with each new instance:
const store2 = new NotificationStore({
404: 'not here'
});
or, you can call the loadMessages
method on the instance:
store.loadMessages({
404: 'not here'
});
In either case, you need to set the allowOverrides
option to true or the existing messages will be preserved.
To trigger a notification, you call the triggerNotification
method on your store instance. Provide a handle, a (optional) target and some (also optional) extra options:
const store = new NotificationStore({
404: 'not found'
});
store.triggerNotification('404', 'statusbar', { timer: 1000 });
You can clear a notification by calling the clearNotification
method on the store:
const notifications = store.getNotifications('statusbar');
const notificationToClear = notifications.find(notification => notification.handle === 'clearme');
store.clearNotification(notificationToClear);
Each instance has a notifications
property, which holds all current notifications as a BehaviorSubject
which you can subscribe to:
store.notifications.subscribe(newNotifications => {
// do something
});
or fetch the current value from (which is an object with a Map of the notifications for each target:
const notifications = store.notifications.getValue();
Static properties
defaultOptions
(object): returns a plain object with the default optionsavailableTypes
(object): getter for the available notification typesStatic methods
parseOptions(options)
: check the provided options against the default optionsInstance properties
handle
(string): the unique handle for the notification messagetarget
(string): the target to store the notification withmessage
(string): the message to be shown when triggering the notificationtype
(string): the type of notification (N, I, E, W, S)timer
(number): the lifespan of the notification once it is shown (in ms)scope
(string): the app scope the notification should be visible inStatic properties
allowOverrides
(boolean): get/set for the allowOverrides optiondefaultHandle
(string): get/set for the default handle to fall back to when triggering a notificationdefaultTarget
(string): get/set for the default target to fall back to when triggering a notificationdefaultMessage
(string): get/set for the default message to fall back to when triggering a notificationdefaultTimer
(number): get/set for the default timer to fall back to when triggering a notificationdefaultScope
(string): get/set for the default scope to fall back to when triggering a notificationmessages
(object): get/set for the available messagesoptions
(object): get/set for the currently selected optionssubjects
(Map): getter for the current subjectsStatic methods
subscriber(store)
: add a new BehaviorSubject for a store (internal function)getFlatTarget(target)
: get the notifications as a flat array for a target (internal function)getFlatNotifications(target)
: get the notifications (for a target if provided) as a flat object of target arrays (internal function)deleteNotification(notification)
: delete a notification (internal function)updateSubjects()
: trigger an update to all subjects (internal function)resetStore()
: clear all messages and notifications and reset all optionsInstance properties
notifications
(BehaviorSubject): a BehaviorSubject that holds all current notificationsInstance methods
getMessages
: get the stored messagesgetMessage(handle)
: get a message by its handleloadMessages(messages)
: load a new set of messages (takes the allowOverrides
option into account)triggerNotification(handle, target, options)
: trigger a new notification by handle, target and provide some extra optional optionsloadNotification(notification)
: load a new notification, needs a Notification
instancegetNotifications(target)
: return a flat object holding all notifications or the notifications for the provided targetclearNotification(notification)
: clear a notification, needs a Notification
instanceclearTarget(target)
: clear all notifications for a target, target is requiredFAQs
The Notification Store provides a singleton store to save and easily access notifications throughout your app.
The npm package @acpaas-ui/js-notification-store receives a total of 10 weekly downloads. As such, @acpaas-ui/js-notification-store popularity was classified as not popular.
We found that @acpaas-ui/js-notification-store demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.