lib/pakyow/ui/behavior/rendering.rb in pakyow-ui-1.0.0.rc3 vs lib/pakyow/ui/behavior/rendering.rb in pakyow-ui-1.0.0.rc4
- old
+ new
@@ -49,27 +49,38 @@
metadata = {
renderer: ui_renderer_instance
}
- payload = {
+ @payload = {
metadata: Marshal.dump(metadata)
}
# Generate a unique id based on the value of the metadata. This guarantees that the
# transformation id will be consistent across subscriptions.
#
- transformation_id = Digest::SHA1.hexdigest(payload[:metadata])
+ transformation_id = Digest::SHA1.hexdigest(@payload[:metadata])
presentables[:__transformation_id] = transformation_id
- payload[:transformation_id] = transformation_id
+ @payload[:transformation_id] = transformation_id
+ @payload[:id] = transformation_id
+ end
+ end
+ end
+ after "render" do
+ if instance_variable_defined?(:@payload)
+ @app.ui_executor.post(self, subscribables, @payload, Pakyow.logger.target) do |context, subscribables, payload, logger|
+ logger.internal {
+ "[ui] subscribing #{@payload[:id]}"
+ }
+
# Find every subscribable presentable, creating a data subscription for each.
#
subscribables.each do |subscribable|
- subscribable.subscribe(socket_client_id, handler: Handler, payload: payload) do |ids|
+ subscribable.subscribe(context.socket_client_id, handler: Handler, payload: payload) do |ids|
# Subscribe the subscriptions to the "transformation" channel.
#
- subscribe(:transformation, *ids.uniq)
+ context.subscribe(:transformation, *ids.uniq)
end
end
end
end
end