volt 0.7.10 → 0.7.12
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/VERSION +1 -1
- data/app/volt/tasks/live_query/live_query.rb +4 -4
- data/app/volt/tasks/live_query/live_query_pool.rb +0 -1
- data/app/volt/tasks/query_tasks.rb +1 -1
- data/app/volt/tasks/store_tasks.rb +0 -3
- data/lib/volt/assets/test.rb +0 -1
- data/lib/volt/cli/asset_compile.rb +0 -1
- data/lib/volt/models/array_model.rb +0 -1
- data/lib/volt/models/model.rb +0 -3
- data/lib/volt/models/persistors/array_store.rb +0 -6
- data/lib/volt/models/persistors/model_store.rb +0 -1
- data/lib/volt/page/bindings/attribute_binding.rb +0 -5
- data/lib/volt/page/bindings/base_binding.rb +0 -1
- data/lib/volt/page/bindings/content_binding.rb +0 -1
- data/lib/volt/page/bindings/each_binding.rb +0 -5
- data/lib/volt/page/bindings/event_binding.rb +0 -1
- data/lib/volt/page/bindings/if_binding.rb +0 -1
- data/lib/volt/page/bindings/template_binding.rb +0 -2
- data/lib/volt/page/document_events.rb +0 -5
- data/lib/volt/page/page.rb +3 -4
- data/lib/volt/page/reactive_template.rb +0 -14
- data/lib/volt/page/targets/attribute_section.rb +0 -1
- data/lib/volt/page/targets/dom_section.rb +0 -1
- data/lib/volt/page/tasks.rb +0 -2
- data/lib/volt/page/template_renderer.rb +1 -14
- data/lib/volt/reactive/event_chain.rb +0 -2
- data/lib/volt/reactive/events.rb +0 -11
- data/lib/volt/reactive/reactive_array.rb +0 -1
- data/lib/volt/reactive/reactive_count.rb +0 -4
- data/lib/volt/reactive/reactive_value.rb +0 -10
- data/lib/volt/server.rb +1 -0
- data/lib/volt/server/component_handler.rb +0 -3
- data/lib/volt/server/socket_connection_handler.rb +0 -1
- data/spec/models/reactive_value_spec.rb +0 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85bcb7f3f097162cab94d1d62b649fe2d37cea1a
|
4
|
+
data.tar.gz: eec2788d9fa80fdbe0ee61386f40f8ce13f194af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf2f03dc33ec3637a1d18b8a0a50a791fce3707b858ca7e9b78ded620dbf5e2931433648cf750313bb6c340fe79481830dbd28707083f4524e41702a2b72b2cb
|
7
|
+
data.tar.gz: 24ebe1c03fb1f43bd1cb7d49e51593a8bd7a1165df62936310a3040903592c3d6ef17c84bca3639928e7dac97801e4e1a5c38028f4f9fdfb22347235f303c93b
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.12
|
@@ -24,28 +24,28 @@ class LiveQuery
|
|
24
24
|
|
25
25
|
def notify_removed(ids, skip_channel)
|
26
26
|
notify! do |channel|
|
27
|
-
puts "Removed: #{ids.inspect} to #{channel.inspect}"
|
27
|
+
# puts "Removed: #{ids.inspect} to #{channel.inspect}"
|
28
28
|
channel.send_message("removed", nil, @collection, @query, ids)
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
def notify_added(index, data, skip_channel)
|
33
33
|
notify! do |channel|
|
34
|
-
puts "Added: #{index} - #{data.inspect} to #{channel.inspect}"
|
34
|
+
# puts "Added: #{index} - #{data.inspect} to #{channel.inspect}"
|
35
35
|
channel.send_message("added", nil, @collection, @query, index, data)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
39
|
def notify_moved(id, new_position, skip_channel)
|
40
40
|
notify! do |channel|
|
41
|
-
puts "Moved: #{id}, #{new_position} to #{channel.inspect}"
|
41
|
+
# puts "Moved: #{id}, #{new_position} to #{channel.inspect}"
|
42
42
|
channel.send_message("moved", nil, @collection, @query, id, new_position)
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
def notify_changed(id, data, skip_channel)
|
47
47
|
notify!(skip_channel) do |channel|
|
48
|
-
puts "Changed: #{id}, #{data} to #{channel.inspect}"
|
48
|
+
# puts "Changed: #{id}, #{data} to #{channel.inspect}"
|
49
49
|
channel.send_message("changed", nil, @collection, @query, id, data)
|
50
50
|
end
|
51
51
|
end
|
@@ -15,7 +15,6 @@ class LiveQueryPool < GenericPool
|
|
15
15
|
|
16
16
|
def updated_collection(collection, skip_channel)
|
17
17
|
lookup_all(collection).each do |live_query|
|
18
|
-
puts "RUN ON: #{live_query} with #{live_query.instance_variable_get('@channels').inspect}"
|
19
18
|
live_query.run(skip_channel)
|
20
19
|
end
|
21
20
|
end
|
@@ -19,7 +19,7 @@ class QueryTasks
|
|
19
19
|
live_query = @@live_query_pool.lookup(collection, query)
|
20
20
|
track_channel_in_live_query(live_query)
|
21
21
|
|
22
|
-
puts "Load data on #{collection.inspect} - #{query.inspect}"
|
22
|
+
# puts "Load data on #{collection.inspect} - #{query.inspect}"
|
23
23
|
live_query.add_channel(@channel)
|
24
24
|
|
25
25
|
errors = {}
|
@@ -32,7 +32,6 @@ class StoreTasks
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def save(collection, data)
|
35
|
-
puts "Insert: #{data.inspect} on #{collection.inspect}"
|
36
35
|
data = data.symbolize_keys
|
37
36
|
|
38
37
|
errors = model_errors(collection, data)
|
@@ -56,7 +55,6 @@ class StoreTasks
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
puts "SAVE: #{@channel.inspect}"
|
60
58
|
QueryTasks.live_query_pool.updated_collection(collection, @channel)
|
61
59
|
return {}
|
62
60
|
else
|
@@ -65,7 +63,6 @@ class StoreTasks
|
|
65
63
|
end
|
66
64
|
|
67
65
|
def delete(collection, id)
|
68
|
-
puts "DELETE: #{collection.inspect} - #{id.inspect}"
|
69
66
|
@@db[collection].remove('_id' => id)
|
70
67
|
|
71
68
|
QueryTasks.live_query_pool.updated_collection(collection, @channel)
|
data/lib/volt/assets/test.rb
CHANGED
@@ -3,4 +3,3 @@ require 'sass'
|
|
3
3
|
sass_engine = Sass::Engine.new(template, {syntax: :scss, filename: 'cool.css.scss', sourcemap: true}) ; output =
|
4
4
|
sass_engine.render_with_sourcemap('/source_maps/')
|
5
5
|
|
6
|
-
puts a[1].to_json(:css_path => '/cool.css', :sourcemap_path => '/source_maps/cool.css.map')
|
@@ -41,7 +41,6 @@ class CLI
|
|
41
41
|
javascript_code = Opal.compile(code)
|
42
42
|
|
43
43
|
components_folder = File.join(Volt.root, '/public/components')
|
44
|
-
puts "CF: #{components_folder}"
|
45
44
|
FileUtils.mkdir_p(components_folder)
|
46
45
|
File.open(File.join(components_folder, '/main.js'), 'w') do |file|
|
47
46
|
file.write(javascript_code)
|
data/lib/volt/models/model.rb
CHANGED
@@ -318,8 +318,6 @@ class Model
|
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
-
# puts "SAVE TO:: #{model.options[:save_to].inspect} for #{model.inspect}"
|
322
|
-
|
323
321
|
return ReactiveValue.new(model)
|
324
322
|
end
|
325
323
|
|
@@ -340,7 +338,6 @@ class Model
|
|
340
338
|
def __clear_element(key)
|
341
339
|
# Cleanup any tracking on an index
|
342
340
|
# TODO: is this send a security risk?
|
343
|
-
# puts "TRY TO CLEAR: #{key} - #{@reactive_element_listeners && @reactive_element_listeners.keys.inspect}"
|
344
341
|
if @reactive_element_listeners && @reactive_element_listeners[key]
|
345
342
|
@reactive_element_listeners[key].remove
|
346
343
|
@reactive_element_listeners.delete(key)
|
@@ -15,7 +15,6 @@ module Persistors
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def initialize(model, tasks=nil)
|
18
|
-
# puts "NEW ARRAY STORE FOR #{model.inspect}"
|
19
18
|
super
|
20
19
|
|
21
20
|
query = @model.options[:query]
|
@@ -91,7 +90,6 @@ module Persistors
|
|
91
90
|
end
|
92
91
|
end
|
93
92
|
|
94
|
-
# puts "IN QUERY: #{query.inspect} - #{self.inspect}"
|
95
93
|
@query_listener = @@query_pool.lookup(collection, query) do
|
96
94
|
# Create if it does not exist
|
97
95
|
QueryListener.new(@@query_pool, @tasks, collection, query)
|
@@ -113,7 +111,6 @@ module Persistors
|
|
113
111
|
|
114
112
|
promise = promise.then(&block) if block
|
115
113
|
|
116
|
-
# puts "FETCH: #{@state.inspect}"
|
117
114
|
if @state == :loaded
|
118
115
|
promise.resolve(@model)
|
119
116
|
else
|
@@ -129,7 +126,6 @@ module Persistors
|
|
129
126
|
# Called from backend
|
130
127
|
def add(index, data)
|
131
128
|
$loading_models = true
|
132
|
-
# puts "INSERT: #{data.inspect} into #{self.inspect}"
|
133
129
|
|
134
130
|
new_options = @model.options.merge(path: @model.path + [:[]], parent: @model)
|
135
131
|
|
@@ -138,7 +134,6 @@ module Persistors
|
|
138
134
|
# Find the existing model, or create one
|
139
135
|
new_model = @@identity_map.find(data['_id']) { @model.new_model(data.symbolize_keys, new_options, :loaded) }
|
140
136
|
|
141
|
-
# puts "ADD: #{new_model.attributes.inspect}"
|
142
137
|
@model.insert(index, new_model)
|
143
138
|
end
|
144
139
|
|
@@ -183,7 +178,6 @@ module Persistors
|
|
183
178
|
if defined?($loading_models) && $loading_models
|
184
179
|
return
|
185
180
|
else
|
186
|
-
puts "delete #{channel_name} - #{model.attributes[:_id]}"
|
187
181
|
@tasks.call('StoreTasks', 'delete', channel_name, model.attributes[:_id])
|
188
182
|
end
|
189
183
|
end
|
@@ -3,7 +3,6 @@ require 'volt/page/targets/attribute_target'
|
|
3
3
|
|
4
4
|
class AttributeBinding < BaseBinding
|
5
5
|
def initialize(page, target, context, binding_name, attribute_name, getter)
|
6
|
-
# puts "New Attribute Binding: #{binding_name}, #{attribute_name}, #{getter}"
|
7
6
|
super(page, target, context, binding_name)
|
8
7
|
|
9
8
|
@attribute_name = attribute_name
|
@@ -37,14 +36,11 @@ class AttributeBinding < BaseBinding
|
|
37
36
|
case @attribute_name
|
38
37
|
when 'value'
|
39
38
|
current_value = element.value
|
40
|
-
# puts "NEW VAL: #{current_value} : #{@value.inspect}"
|
41
39
|
else
|
42
40
|
current_value = element.is(':checked')
|
43
41
|
end
|
44
42
|
|
45
|
-
# puts "ASSIGN #{current_value}"
|
46
43
|
@value.cur = current_value
|
47
|
-
# puts "ASSIGNED"
|
48
44
|
end
|
49
45
|
|
50
46
|
def element
|
@@ -91,7 +87,6 @@ class AttributeBinding < BaseBinding
|
|
91
87
|
end
|
92
88
|
|
93
89
|
def remove
|
94
|
-
# puts "REMOVE #{self.inspect}"
|
95
90
|
# Unbind events, leave the element there since attribute bindings
|
96
91
|
# aren't responsible for it being there.
|
97
92
|
case @attribute_name
|
@@ -2,7 +2,6 @@ require 'volt/page/bindings/base_binding'
|
|
2
2
|
|
3
3
|
class ContentBinding < BaseBinding
|
4
4
|
def initialize(page, target, context, binding_name, getter)
|
5
|
-
# puts "new content binding: #{getter}"
|
6
5
|
super(page, target, context, binding_name)
|
7
6
|
|
8
7
|
# Find the source for the content binding
|
@@ -2,8 +2,6 @@ require 'volt/page/bindings/base_binding'
|
|
2
2
|
|
3
3
|
class EachBinding < BaseBinding
|
4
4
|
def initialize(page, target, context, binding_name, getter, variable_name, template_name)
|
5
|
-
# puts "New EACH Binding"
|
6
|
-
|
7
5
|
super(page, target, context, binding_name)
|
8
6
|
|
9
7
|
@item_name = variable_name
|
@@ -53,7 +51,6 @@ class EachBinding < BaseBinding
|
|
53
51
|
|
54
52
|
def item_added(position)
|
55
53
|
# ObjectTracker.enable_cache
|
56
|
-
# puts "ADDED 1"
|
57
54
|
binding_name = @@binding_number
|
58
55
|
@@binding_number += 1
|
59
56
|
|
@@ -82,7 +79,6 @@ class EachBinding < BaseBinding
|
|
82
79
|
size = @templates.size
|
83
80
|
if size > 0
|
84
81
|
start_index.upto(size-1) do |index|
|
85
|
-
puts "UP INDEX: #{index}"
|
86
82
|
@templates[index].context.locals[:index].cur = index
|
87
83
|
end
|
88
84
|
end
|
@@ -100,7 +96,6 @@ class EachBinding < BaseBinding
|
|
100
96
|
|
101
97
|
# When this each_binding is removed, cleanup.
|
102
98
|
def remove
|
103
|
-
# puts "Remove Each"
|
104
99
|
@added_listener.remove
|
105
100
|
@added_listener = nil
|
106
101
|
|
@@ -2,7 +2,6 @@ require 'volt/page/bindings/base_binding'
|
|
2
2
|
|
3
3
|
class IfBinding < BaseBinding
|
4
4
|
def initialize(page, target, context, binding_name, branches)
|
5
|
-
# puts "New If Binding: #{binding_name}, #{getter.inspect}"
|
6
5
|
super(page, target, context, binding_name)
|
7
6
|
|
8
7
|
getter, template_name = branches[0]
|
@@ -4,7 +4,6 @@ require 'volt/page/bindings/template_binding/grouped_controllers'
|
|
4
4
|
|
5
5
|
class TemplateBinding < BaseBinding
|
6
6
|
def initialize(page, target, context, binding_name, binding_in_path, getter)
|
7
|
-
# puts "New template binding: #{context.inspect} - #{binding_name.inspect}"
|
8
7
|
super(page, target, context, binding_name)
|
9
8
|
|
10
9
|
# Binding in path is the path for the template this binding is in
|
@@ -123,7 +122,6 @@ class TemplateBinding < BaseBinding
|
|
123
122
|
|
124
123
|
def update
|
125
124
|
full_path, controller_path = path_for_template(@path.cur, @section.cur)
|
126
|
-
# puts "UPDATE: #{@path.inspect} - #{full_path.inspect}"
|
127
125
|
|
128
126
|
@current_template.remove if @current_template
|
129
127
|
|
@@ -21,14 +21,11 @@ class DocumentEvents
|
|
21
21
|
|
22
22
|
end
|
23
23
|
|
24
|
-
# puts "Register: #{event} - #{binding.binding_name} - #{binding.object_id}"
|
25
|
-
|
26
24
|
@events[event][binding.binding_name] ||= {}
|
27
25
|
@events[event][binding.binding_name][binding.object_id] = handler
|
28
26
|
end
|
29
27
|
|
30
28
|
def handle(event_name, event, target)
|
31
|
-
# puts "Handle: #{event_name} on #{target}"
|
32
29
|
element = Element.find(target)
|
33
30
|
|
34
31
|
loop do
|
@@ -37,8 +34,6 @@ class DocumentEvents
|
|
37
34
|
# TODO: Sometimes the event doesn't exist, but we still get
|
38
35
|
# an event.
|
39
36
|
handlers = @events[event_name]
|
40
|
-
# puts "EVENT: #{event_name} - #{handlers.inspect} for #{element.id}"
|
41
|
-
# `console.log('target: ', target);`
|
42
37
|
handlers = handlers[element.id] if handlers
|
43
38
|
|
44
39
|
if handlers
|
data/lib/volt/page/page.rb
CHANGED
@@ -62,6 +62,9 @@ class Page
|
|
62
62
|
});
|
63
63
|
}
|
64
64
|
end
|
65
|
+
|
66
|
+
# Initialize tasks so we can get the reload message
|
67
|
+
self.tasks if Volt.env.development?
|
65
68
|
end
|
66
69
|
|
67
70
|
def flash
|
@@ -128,13 +131,10 @@ class Page
|
|
128
131
|
end
|
129
132
|
|
130
133
|
def add_model(model_name)
|
131
|
-
# puts "ADD MODEL: #{model_name.inspect} - #{model_name.camelize.inspect}"
|
132
|
-
|
133
134
|
@model_classes[["*", "_#{model_name}"]] = Object.const_get(model_name.camelize)
|
134
135
|
end
|
135
136
|
|
136
137
|
def add_template(name, template, bindings)
|
137
|
-
# puts "Add Template: #{name}\n#{template.inspect}\n#{bindings.inspect}"
|
138
138
|
@templates ||= {}
|
139
139
|
@templates[name] = {'html' => template, 'bindings' => bindings}
|
140
140
|
# puts "Add Template: #{name}"
|
@@ -163,7 +163,6 @@ class Page
|
|
163
163
|
title_target = AttributeTarget.new
|
164
164
|
title_target.on('changed') do
|
165
165
|
title = title_target.to_html
|
166
|
-
# puts "SET TITLE: #{title.inspect}: #{title_target.inspect}"
|
167
166
|
`document.title = title;`
|
168
167
|
end
|
169
168
|
TemplateRenderer.new(self, title_target, main_controller, "main", "main/main/main/title")
|
@@ -2,7 +2,6 @@ class ReactiveTemplate
|
|
2
2
|
include Events
|
3
3
|
|
4
4
|
def initialize(page, context, template_path)
|
5
|
-
# puts "New Reactive Template: #{context.inspect} - #{template_path.inspect}"
|
6
5
|
@template_path = template_path
|
7
6
|
@target = AttributeTarget.new(nil, nil, self)
|
8
7
|
@template = TemplateRenderer.new(page, @target, context, "main", template_path)
|
@@ -13,19 +12,6 @@ class ReactiveTemplate
|
|
13
12
|
true
|
14
13
|
end
|
15
14
|
|
16
|
-
# def event_added(event, scope_provider, first, first_for_event)
|
17
|
-
# if first && !@template_listener
|
18
|
-
# @template_listener = @target.on('changed') { update }
|
19
|
-
# end
|
20
|
-
# end
|
21
|
-
#
|
22
|
-
# def event_removed(event, last, last_for_event)
|
23
|
-
# if last && @template_listener
|
24
|
-
# @template_listener.remove
|
25
|
-
# @template_listener = nil
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
|
29
15
|
# Render the template and get the current value
|
30
16
|
def cur
|
31
17
|
@target.to_html
|
@@ -45,7 +45,6 @@ class DomSection < BaseSection
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def insert_anchor_before(binding_name, insert_after_binding)
|
48
|
-
puts "insert_anchor_before"
|
49
48
|
node = find_by_comment("$#{insert_after_binding}")
|
50
49
|
Element.find(node).before("<!-- $#{binding_name} --><!-- $/#{binding_name} -->")
|
51
50
|
end
|
data/lib/volt/page/tasks.rb
CHANGED
@@ -57,12 +57,10 @@ class Tasks
|
|
57
57
|
# a query.
|
58
58
|
def notify_query(method_name, collection, query, *args)
|
59
59
|
query_obj = Persistors::ArrayStore.query_pool.lookup(collection, query)
|
60
|
-
# puts "FOUND QUERY: #{collection.inspect} - #{query.inspect} - #{query_obj.inspect} - #{method_name} - #{query_obj.instance_variable_get('@stores').inspect}"
|
61
60
|
query_obj.send(method_name, *args)
|
62
61
|
end
|
63
62
|
|
64
63
|
def reload
|
65
|
-
puts "RELOAD"
|
66
64
|
# Stash the current page value
|
67
65
|
value = JSON.dump($page.page.cur.to_h.reject {|k,v| v.reactive? })
|
68
66
|
|
@@ -3,11 +3,8 @@ require 'volt/page/bindings/base_binding'
|
|
3
3
|
class TemplateRenderer < BaseBinding
|
4
4
|
attr_reader :context
|
5
5
|
def initialize(page, target, context, binding_name, template_name)
|
6
|
-
# puts "new template renderer: #{context.inspect} - #{binding_name.inspect}"
|
7
6
|
super(page, target, context, binding_name)
|
8
7
|
|
9
|
-
# puts "Template Name: #{template_name}"
|
10
|
-
|
11
8
|
@sub_bindings = []
|
12
9
|
|
13
10
|
bindings = self.section.set_content_to_template(page, template_name)
|
@@ -20,17 +17,7 @@ class TemplateRenderer < BaseBinding
|
|
20
17
|
end
|
21
18
|
|
22
19
|
def remove
|
23
|
-
|
24
|
-
|
25
|
-
# Remove all of the sub-bindings
|
26
|
-
# @sub_bindings.each(&:remove)
|
27
|
-
|
28
|
-
@sub_bindings.each do |binding|
|
29
|
-
# puts "REMOVE: #{binding.inspect}"
|
30
|
-
binding.remove
|
31
|
-
# puts "REMOVED"
|
32
|
-
end
|
33
|
-
|
20
|
+
@sub_bindings.each(&:remove)
|
34
21
|
@sub_bindings = []
|
35
22
|
|
36
23
|
super
|
@@ -67,8 +67,6 @@ class EventChain
|
|
67
67
|
# We can chain our events to any other object that includes
|
68
68
|
# Events
|
69
69
|
def add_object(object, &block)
|
70
|
-
# puts "ADD OBJECT: #{object.inspect} to #{self.inspect}"
|
71
|
-
|
72
70
|
chain_listener = ChainListener.new(self, object, block)
|
73
71
|
|
74
72
|
listeners = {}
|
data/lib/volt/reactive/events.rb
CHANGED
@@ -62,14 +62,12 @@ class Listener
|
|
62
62
|
|
63
63
|
# Removes the listener from where ever it was created.
|
64
64
|
def remove
|
65
|
-
# puts "FAIL:" if @removed
|
66
65
|
if @removed
|
67
66
|
# raise "event #{@event} already removed"
|
68
67
|
puts "event #{@event} already removed"
|
69
68
|
return
|
70
69
|
end
|
71
70
|
|
72
|
-
# puts "e rem: #{@event} on #{@klass.inspect}"
|
73
71
|
if DEBUG && RUBY_PLATFORM == 'opal'
|
74
72
|
@@all_events.delete(self) if @@all_events
|
75
73
|
|
@@ -81,8 +79,6 @@ class Listener
|
|
81
79
|
@removed = true
|
82
80
|
@klass.remove_listener(@event, self)
|
83
81
|
|
84
|
-
# puts "Removed Listener for: #{@event} - #{@scope_provider && @scope_provider.scope.inspect} from #{@klass.inspect}"
|
85
|
-
|
86
82
|
# We need to clear these references to free the memory
|
87
83
|
@scope_provider = nil
|
88
84
|
@callback = nil
|
@@ -101,7 +97,6 @@ module Events
|
|
101
97
|
# Add a listener for an event
|
102
98
|
def on(event, scope_provider=nil, &block)
|
103
99
|
|
104
|
-
# puts "Register: #{event} on #{self.inspect}"
|
105
100
|
event = event.to_sym
|
106
101
|
|
107
102
|
@has_listeners = true
|
@@ -177,15 +172,10 @@ module Events
|
|
177
172
|
|
178
173
|
def trigger!(event, filter=nil, *args)
|
179
174
|
are_reactive = reactive?
|
180
|
-
# ObjectTracker.process_queue if !are_reactive
|
181
|
-
# puts "DT"
|
182
|
-
# insp = self.inspect
|
183
|
-
# puts "TRIGGER #{event} on #{insp}"
|
184
175
|
|
185
176
|
event = event.to_sym
|
186
177
|
|
187
178
|
if @listeners && @listeners[event]
|
188
|
-
# puts "LISTENERS FOR #{event} on #{self.inspect} - #{@listeners[event].inspect}"
|
189
179
|
# TODO: We have to dup here because one trigger might remove another
|
190
180
|
@listeners[event].dup.each do |listener|
|
191
181
|
# Call the event on each listener
|
@@ -194,7 +184,6 @@ module Events
|
|
194
184
|
# if we aren't reactive, we should pass to all of our reactive listeners, since they
|
195
185
|
# just proxy us.
|
196
186
|
# If the filter exists, check it
|
197
|
-
# puts "CHECK #{listener.inspect} : #{self.inspect} -- #{listener.klass.inspect}"
|
198
187
|
if (!filter || (!are_reactive && listener.scope_provider.reactive?) || filter.call(listener.scope))
|
199
188
|
listener.call(filter, *args)
|
200
189
|
end
|
@@ -208,7 +208,6 @@ class ReactiveArray# < Array
|
|
208
208
|
self.trigger_by_scope!(event_name, *passed_args) do |scope|
|
209
209
|
# method_name, *args, block = scope
|
210
210
|
method_name, args, block = split_scope(scope)
|
211
|
-
# puts "SCOPE CHECK: TFI: #{method_name.inspect} - #{args.inspect} on #{self.inspect}"
|
212
211
|
|
213
212
|
result = case method_name
|
214
213
|
when nil
|
@@ -36,7 +36,6 @@ class ReactiveCount
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def setup_listeners
|
39
|
-
puts "SETUP LISTENERS"
|
40
39
|
@cell_trackers = []
|
41
40
|
@added_tracker = @source.on('added') do |_, index|
|
42
41
|
change_cell_count(@source.size.cur)
|
@@ -65,7 +64,6 @@ class ReactiveCount
|
|
65
64
|
val = @source[index]
|
66
65
|
|
67
66
|
result = @block.call(val)
|
68
|
-
# puts "TRACK AT #{index} on #{result.inspect}"
|
69
67
|
|
70
68
|
@cell_trackers << result.on('changed') do
|
71
69
|
trigger!('changed')
|
@@ -73,7 +71,6 @@ class ReactiveCount
|
|
73
71
|
end
|
74
72
|
elsif current_size > size
|
75
73
|
(current_size-1).downto(size) do |index|
|
76
|
-
# puts "Remove at: #{index}"
|
77
74
|
@cell_trackers[index].remove
|
78
75
|
@cell_trackers.delete_at(index)
|
79
76
|
end
|
@@ -91,7 +88,6 @@ class ReactiveCount
|
|
91
88
|
change_cell_count(0)
|
92
89
|
|
93
90
|
@cell_trackers = nil
|
94
|
-
puts "TEARDOWN"
|
95
91
|
end
|
96
92
|
|
97
93
|
def event_added(event, scope_provider, first, first_for_event)
|
@@ -101,7 +101,6 @@ class ReactiveValue < BasicObject
|
|
101
101
|
# TODO: Should cache the lookup on pass_reactive
|
102
102
|
pass_args = reactive_manager.unwrap_if_pass_reactive(in_args, method_name, val)
|
103
103
|
|
104
|
-
# puts "GET #{method_name.inspect}"
|
105
104
|
val.__send__(method_name, *pass_args, &block)
|
106
105
|
end
|
107
106
|
|
@@ -114,7 +113,6 @@ class ReactiveValue < BasicObject
|
|
114
113
|
# result = result.with(block_reactives) if block
|
115
114
|
|
116
115
|
# if args.size == 0 || method_name == :[]
|
117
|
-
# puts "STORE: #{method_name} - #{args.inspect}"
|
118
116
|
# @reactive_cache[[method_name, args.map(&:object_id)]] = result
|
119
117
|
# end
|
120
118
|
|
@@ -144,7 +142,6 @@ class ReactiveValue < BasicObject
|
|
144
142
|
# end
|
145
143
|
|
146
144
|
def respond_to_missing?(name, include_private=false)
|
147
|
-
puts "RT"
|
148
145
|
cur.respond_to?(name)
|
149
146
|
end
|
150
147
|
|
@@ -244,7 +241,6 @@ class ReactiveManager
|
|
244
241
|
def cur(shallow=false, ignore_cache=false)
|
245
242
|
# Return from cache if it is cached
|
246
243
|
if @cur_cache && !shallow && !ignore_cache
|
247
|
-
# puts "From Cache: #{@cur_cache.inspect}"
|
248
244
|
return @cur_cache
|
249
245
|
end
|
250
246
|
|
@@ -265,8 +261,6 @@ class ReactiveManager
|
|
265
261
|
result = result.cur
|
266
262
|
end
|
267
263
|
|
268
|
-
# puts "CUR FOR: #{result.inspect}"
|
269
|
-
|
270
264
|
return result
|
271
265
|
end
|
272
266
|
|
@@ -275,14 +269,11 @@ class ReactiveManager
|
|
275
269
|
if has_listeners?
|
276
270
|
current_obj = cur(false, true)
|
277
271
|
should_attach = current_obj.respond_to?(:on)
|
278
|
-
# puts "SA #{should_attach} - #{current_obj.inspect}"
|
279
272
|
|
280
273
|
if should_attach
|
281
274
|
if !@cur_cache || current_obj.object_id != @cur_cache.object_id
|
282
|
-
# puts "CHANGED FROM: #{@cur_cache.inspect} to #{current_obj.inspect} - #{current_obj.object_id} vs #{@cur_cache.object_id}"
|
283
275
|
remove_followers
|
284
276
|
|
285
|
-
# puts "SET TO: #{current_obj.inspect} on #{self.inspect}"
|
286
277
|
@cur_cache_chain_listener = self.event_chain.add_object(current_obj)
|
287
278
|
end
|
288
279
|
else
|
@@ -295,7 +286,6 @@ class ReactiveManager
|
|
295
286
|
end
|
296
287
|
|
297
288
|
def remove_followers
|
298
|
-
# puts "REMOVE FOLLOWERS: #{@cur_cache.inspect} on #{self.inspect}"
|
299
289
|
# Remove from previous
|
300
290
|
if @cur_cache
|
301
291
|
@cur_cache = nil
|
data/lib/volt/server.rb
CHANGED
@@ -69,6 +69,7 @@ class Server
|
|
69
69
|
def setup_change_listener
|
70
70
|
# Setup the listeners for file changes
|
71
71
|
listener = Listen.to("#{@app_path}/") do |modified, added, removed|
|
72
|
+
puts "file changed, sending reload"
|
72
73
|
SocketConnectionHandler.send_message_all(nil, 'reload')
|
73
74
|
end
|
74
75
|
listener.start
|
@@ -15,11 +15,8 @@ class ComponentHandler
|
|
15
15
|
|
16
16
|
code = ComponentCode.new(component_name, @component_paths).code
|
17
17
|
|
18
|
-
# puts "CODE: #{code}"
|
19
|
-
|
20
18
|
javascript_code = Opal.compile(code)
|
21
19
|
|
22
|
-
# puts "ENV: #{env.inspect}"
|
23
20
|
[200, {"Content-Type" => "text/html; charset=utf-8"}, StringIO.new(javascript_code)]
|
24
21
|
end
|
25
22
|
|