angular-faye-rails 0.1.0 → 0.1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -31
- data/lib/angular-faye-rails.rb +9 -0
- data/lib/angular-faye-rails/version.rb +1 -1
- data/vendor/assets/javascripts/angular-faye.js.coffee +24 -22
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80cdfeb7cc2575b70abc2b10ef65286fc98bab38
|
4
|
+
data.tar.gz: 9902dea212e90f7fb10461624eb3df68f17c95f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 720288a651bec51d04540c38b4797b993d73958cf7275228609542c157e49d9f332a1d2c23655c23d3f67f18b77598b458e0c2f46da5bddf834767bb2ffa637f
|
7
|
+
data.tar.gz: c64aa8c443ca9e37bf3f0d0f8dc7e6e9f987978f460897e6377dd90790b555d7d9a3ffe5ede014076ada2c78160c35c2341925ad65dbeeb14440801d620677e0
|
data/README.md
CHANGED
@@ -5,6 +5,8 @@
|
|
5
5
|
Add the following to your gemfile:
|
6
6
|
|
7
7
|
```ruby
|
8
|
+
gem "faye"
|
9
|
+
gem "angular-rails"
|
8
10
|
gem "angular-faye-rails"
|
9
11
|
```
|
10
12
|
|
@@ -14,42 +16,16 @@ Add the following directive to your Javascript manifest file (application.js):
|
|
14
16
|
//= require angular-faye
|
15
17
|
```
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
### HTML
|
19
|
+
Add the following to your HTML layout
|
20
20
|
|
21
|
-
```
|
22
|
-
|
23
|
-
<script type="text/javascript" src="/js/angular-faye.js"></script>
|
24
|
-
<script type="text/javascript" src="http://localhost:9292/faye/client.js"></script>
|
25
|
-
<script type="text/javascript" src="/js/app.js"></script>
|
21
|
+
```erb
|
22
|
+
<%= javascript_include_tag "http://localhost:9292/faye/client.js" %>
|
26
23
|
```
|
27
24
|
|
28
|
-
### JavaScript (app.js)
|
29
|
-
|
30
|
-
```js
|
31
|
-
var app = angular.module('myapp', ['faye']);
|
32
|
-
|
33
|
-
app.factory('Faye', ['$faye', function($faye) {
|
34
|
-
return $faye("http://localhost:9292/faye"); // set faye url in one place
|
35
|
-
}]);
|
36
25
|
|
37
|
-
|
38
|
-
// Publish
|
39
|
-
Faye.publish("/channel-1", {msg: "hello"});
|
40
|
-
|
41
|
-
// Subscribe
|
42
|
-
$scope.data = [];
|
43
|
-
Faye.subscribe("/channel-2", function(msg) {
|
44
|
-
$scope.data.push(msg);
|
45
|
-
});
|
46
|
-
|
47
|
-
// Get just once (using $q - promise)
|
48
|
-
$scope.data = Faye.get("/channel-3");
|
49
|
-
};
|
50
|
-
```
|
26
|
+
## Example
|
51
27
|
|
52
|
-
### CoffeeScript
|
28
|
+
### CoffeeScript
|
53
29
|
|
54
30
|
```coffee
|
55
31
|
app = angular.module('myapp', ['faye'])
|
@@ -1,23 +1,25 @@
|
|
1
|
-
angular
|
1
|
+
# = require angular
|
2
2
|
|
3
|
-
angular.module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
3
|
+
angular.module "faye", []
|
4
|
+
|
5
|
+
angular.module("faye").factory "$faye", ["$q", "$rootScope", ($q, $rootScope) ->
|
6
|
+
(url) ->
|
7
|
+
scope = $rootScope
|
8
|
+
client = new Faye.Client(url)
|
9
|
+
publish: (channel, data) ->
|
10
|
+
client.publish channel, data
|
11
|
+
|
12
|
+
subscribe: (channel, callback) ->
|
13
|
+
client.subscribe channel, (data) ->
|
14
|
+
scope.$apply ->
|
15
|
+
callback(data)
|
16
|
+
|
17
|
+
get: (channel) ->
|
18
|
+
deferred = $q.defer()
|
19
|
+
sub = client.subscribe(channel, (data) ->
|
20
|
+
scope.$apply ->
|
21
|
+
deferred.resolve data
|
22
|
+
sub.cancel()
|
23
|
+
)
|
24
|
+
deferred.promise
|
25
|
+
]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: angular-faye-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tymon Tobolski
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
54
|
- angular-faye-rails.gemspec
|
55
|
+
- lib/angular-faye-rails.rb
|
55
56
|
- lib/angular-faye-rails/version.rb
|
56
57
|
- vendor/assets/javascripts/angular-faye.js.coffee
|
57
58
|
homepage: http://github.com/rails-assets/angular-faye-rails
|