
Product
Introducing the Alert Details Page: A Better Way to Explore Alerts
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.
Slots does just that, it provides slots for your event emitter bonds! There is also a SlotManager for combining your slots from different emitters, giving you a single interface for wrangling all your bonds.
A slot is an object that holds the bond between a callback, and an event emitter. This is convenient because you can just tell the slot to disconnect, without having to remember both parts of the bond.
With socket.io, one usually only wants a user to be able to perform an action in a certain state. Such as being able to kick other players if they are the host of the game. With Slots— you can simply remove the event callback for players who aren't host, as opposed to writing logic instead the callback to verify the player's state.
A great way to handle 'state' is with a state graph. It keeps your code simple, and your state isolated. Below is some pseudo-code to illustrate my example of hosts only being able to click players:
function Player(socket, game, isHost) {
var graph = new StateGraph();
graph.state('host', function (state) {
// When the player enters the host state, bind the kick event
state.slot = socket.on('kick', function (player) {
game.kick(player);
});
}).on('end', function (state) {
// Disconnect the kick event when the player is no longer a host
state.slot.remove();
});
graph.state('player', function () {
// Poor players... they can't do anything!
});
if (isHost) {
graph.go('host');
} else {
graph.go('player');
}
return {
host: function () {
graph.go('host');
},
player: function () {
graph.go('player');
}
};
}
FAQs
Slot manager for event emitters!
We found that slots demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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.

Product
Socket's new Alert Details page is designed to surface more context, with a clearer layout, reachability dependency chains, and structured review.

Product
Campaign-level threat intelligence in Socket now shows when active supply chain attacks affect your repositories and packages.

Research
Malicious PyPI package sympy-dev targets SymPy users, a Python symbolic math library with 85 million monthly downloads.