https://github.com/esbenp/knockout-subscriptions-manager
https://github.com/esbenp/knockout-subscriptions-manager
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/esbenp/knockout-subscriptions-manager
- Owner: esbenp
- License: apache-2.0
- Created: 2015-03-28T14:00:35.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-30T20:51:02.000Z (about 10 years ago)
- Last Synced: 2025-02-22T20:08:07.508Z (4 months ago)
- Language: JavaScript
- Size: 188 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.org/esbenp/knockout-subscriptions-manager)
# knockout-subscriptions-managerA small manager to store and dispose multiple knockout.js subscriptions
# Dependencies
* jQuery >= 1.1.4 (used for $.extend)
# Installation
Can be installed via bower package```
bower install --save knockout-subscriptions-manager
```
... or by cloning the repository```
git clone [email protected]:esbenp/knockout-subscriptions-manager.git
```
... or by grabbing a zip of the latest release# Small example
See examples directory for more
```javascript
var manager = new SubscriptionsManager();var observable1 = ko.observable("Observable 1");
var observable2 = ko.observable("Observable 2");
var observable3 = ko.observable("Observable 3");manager.addSubscription(observable1.subscribe(function(newValue){
console.log("Observable 1 value changed");
}));var subscriptions = [
observable2.subscribe(function(newValue){
console.log("Observable 2 value changed");
}),
observable3.subscribe(function(newValue){
console.log("Observable 3 value changed");
})
];manager.addSubscriptions(subscriptions);
manager.disposeAll();
```# License
Copyright © 2015 Esben Petersen & ContributorsLicensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.