6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'app/helpers/solid_objects/actor_helper.rb', line 6
def solid_object(reference, authorization_context: self, &block)
actor = ActorView.new(
reference:,
view_context: self,
authorization_context:
)
content = capture(actor, &block)
subscription_data = {
token: StreamToken.generate(
reference,
observables: actor.scalar_observable_names
)
}
if actor.component_tokens.any?
subscription_data[:components] = JSON.generate(actor.component_tokens)
end
subscription = tag.turbo_cable_stream_source(
channel: "SolidObjects::ActorChannel",
data: subscription_data
)
refresh_client = if actor.morph_components?
javascript_include_tag(
"solid_objects/component_refresh",
type: "module",
data: { turbo_track: "reload" }
)
end
content_tag(
:div,
safe_join([ refresh_client, subscription, content ].compact),
id: DomIdentity.scope(reference)
)
end
|