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