Sha256: 283e0bd8ac94c4953837036bf1f1a0cee5871bfe9c0b6934c1fd7a915f6e8c50
Contents?: true
Size: 846 Bytes
Versions: 2
Compression:
Stored size: 846 Bytes
Contents
module Danthes module ViewHelpers # Publish the given data or block to the client by sending # a Net::HTTP POST request to the Faye server. If a block # or string is passed in, it is evaluated as JavaScript # on the client. Otherwise it will be converted to JSON # for use in a JavaScript callback. def publish_to(channel, data = nil, &block) Danthes.publish_to(channel, data || capture(&block)) end # Subscribe the client to the given channel. This generates # some JavaScript calling Danthes.sign with the subscription # options. def subscribe_to(channel) subscription = Danthes.subscription(channel: channel) content_tag 'script', type: 'text/javascript' do raw("if (typeof Danthes != 'undefined') { Danthes.sign(#{subscription.to_json}) }") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
danthes-2.0.1 | lib/danthes/view_helpers.rb |
danthes-2.0.0 | lib/danthes/view_helpers.rb |