Meteor package that extends the Session API with toggle() and clear() methods.
Package that extends the Session API, with toggle(), clear(), and setAll() methods.
First, install the session-extended-api package from the command line, like so:
meteor add clinical:session-extended-api
The Session object will support the following API with this package installed:
Session.set()
Session.setDefault()
Session.setAll()
Session.get()
Session.equals()
Session.toggle()
Session.clear()
View the TinyTests results by doing the following:
cd myapp/packages/session-extended-api
meteor test-packages
Session.toggle(key) Toggle a variable true/false in the session.
//example
Session.setDefault("widgetIsOpen", false);
Template.myTemplate.events({
'click #displayWidgetButton':function(){
Session.toggle("widgetIsOpen");
}
});
Session.clear(key) Toggle a variable true/false in the session.
//example
Session.setDefault("selectedPurchaseItemId", Meteor.user().profile.selectedItemId);
Template.myTemplate.events({
'click #emptyShoppingCart':function(){
Session.clear("selectedPurchaseItemId");
}
});
MIT License. Use as you will.