
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@salla.sa/event
Advanced tools
Salla JS Events is based on the Event-Driven Architecture, which is a modern design approach centered on data that represents "events" (i.e., a product has been added to the cart).
Explore our blogs »
Report Bug ·
Request Feature .
</Salla Developers> .
Official Documentation
In event-driven programming, an event is the result of a single or multiple actions. Subscribers can listen to that event and take action after it is released by the emitter. In other words, emitters can send events containing data that subscribers can use, and subscribers can use the data to do actions.
Salla JS Events uses EventEmitter2, which is an implementation of the EventEmitter module found in Node.js. It not only outperforms EventEmitter in benchmarks and is browser-compatible, but it also adds a slew of new non-breaking functionality to the EventEmitter interface.
Salla JS Events can be installed from the npm
using the following commands:
npm install @salla.sa/salla-event --save
yarn add @salla.sa/salla-event
Salla JS Events can be triggered by the emitter's 'emit()' method. This method causes the event to be pushed using the data that the developer has provided.
For example, the developer may create an event based on verified login by the user. Simply, the emit()
method can be called with a list of parameters. These parameters state the event's action and the passed data along with it as below:
// via event name
salla.event.emit("auth::verified", {success: true}, 'email')
After creating the event along with its list of data, the next step is to implement an appropriate listener for that event. In Salla JS Events, this can be achieved using two methods:
// via event name
salla.event.on('auth::verified',(response, authType) => {
// lets do anything when the event emit
console.log('The customer has been verifed');
console.log(response, authType)
});
one
time listener for the event along with an anonymized function to perform the needed action based on the event result.// Adds a one time listener for the event.
salla.event.once('auth::verified',(response, authType) => {
// The listener is invoked only the first time
// the event is fired, after which it is removed.
console.log('The customer has been verifed');
console.log(response, authType)
})
The team is always here to help you. Happen to face an issue? Want to report a bug? You can submit one here on Github using the Issue Tracker. If you still have any questions, please contact us via the Telegram Bot or join in the Global Developer Community on Telegram.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
git checkout -b feature/AmazingFeature
)git commit -m 'Add some AmazingFeature'
)git push origin feature/AmazingFeature
)The MIT License (MIT). Please see License File for more information.
FAQs
Twilight events
The npm package @salla.sa/event receives a total of 52 weekly downloads. As such, @salla.sa/event popularity was classified as not popular.
We found that @salla.sa/event demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 37 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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.