ng-orwell

1.1.2 • Public • Published

ngOrwell

A simple angular observer for AngularJs 1

Install

You can install this package either with npm or with bower.

npm

npm install ng-orwell

Then add ng-orwell as a dependency for your app:

angular.module('myApp', [require('ng-orwell')]);

bower

bower install ng-orwell

Add a <script> to your index.html:

<script src="/bower_components/ng-orwell/Orwell.js"></script>

Then add ngOrwell as a dependency for your app:

angular.module('myApp', ['ngOrwell']);

Documentation

Orwell is a simple to use observable for AngularJs 1.

Including orwell in angular

myApp.controller('myController', function(Orwell){

}

Creating a observable

Orwell.createObservable(name, content);

Getting an observable

Orwell.getObservable(name);

Updating content on an observable

This will call all your observer callbacks who are observing this observable.

var myContent = {
  something: 'something'
};
var observable = Orwell.getObservable(name);
observable.setContent(myContent);

Deleting an observable

Orwell.deleteObservable(name);

Adding an observer to an observable

var observable = Orwell.getObservable(name);
var observer = observable.addObserver(function(content){
  // your callback code here.
})

Destroying an observer

var observable = Orwell.getObservable(name);
var observer = observable.addObserver(function(content){
  // your callback code here.
})
$scope.$on('destroy', function(){
  observable.removeObserver(observer);
});

License

Apache 2.0

Package Sidebar

Install

npm i ng-orwell

Weekly Downloads

4

Version

1.1.2

License

Apache-2.0

Last publish

Collaborators

  • joshellinger