reactive-router 0.7.10 → 0.7.11
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/lib/reactive-router/history.rb +24 -2
- data/lib/reactive-router/router.rb +1 -1
- data/lib/reactive-router/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9e13f32bcb8346671dbb38dac2ebf5a2365bcab
|
4
|
+
data.tar.gz: 96a5ecc6d7c25a3b6980564aedbe86e7939a9053
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c178788272d94fc46bade0dc418ea910f824284f972463a8db2dd53e39458267eae83b9dade865c17bd436eba36ef575f16a8b2955dab283338baa6b34f9706
|
7
|
+
data.tar.gz: 245189488f47aeeb4d086a470dda6dcec13a45a0139b35a8f6cabe8026c4946ff0d7ce41be33fe14ce297c9f5b968bc2fd7e30aa597336d9f65ee5f29ebc5abf
|
@@ -35,6 +35,9 @@ class History
|
|
35
35
|
if `event.state == null` # happens when popping off outer dialog
|
36
36
|
puts "pop handler pops off last value"
|
37
37
|
old_history = @history
|
38
|
+
@saved_history = @history # for safari's sake
|
39
|
+
@saved_path = @current_path
|
40
|
+
@saved_history_length = `ReactRouter.History.length`
|
38
41
|
@current_path = ""
|
39
42
|
@history = nil
|
40
43
|
`ReactRouter.History.length = 0`
|
@@ -61,6 +64,12 @@ class History
|
|
61
64
|
|
62
65
|
def push_path(path)
|
63
66
|
puts "pushing path #{path}"
|
67
|
+
unless @history # needed because safari strangly pops off outer most history on initialization
|
68
|
+
@history = @saved_history
|
69
|
+
@current_path = @saved_path
|
70
|
+
`ReactRouter.History.length = #{@saved_history_length}`
|
71
|
+
@history.on_state_change.call(:active) if @history.on_state_change
|
72
|
+
end
|
64
73
|
`window.history.pushState({ path: path, history_id: #{@history.name}, history_length: (ReactRouter.History.length += 1)}, '', path);`
|
65
74
|
@current_path = path
|
66
75
|
@history.notify_listeners(:push)
|
@@ -68,6 +77,12 @@ class History
|
|
68
77
|
|
69
78
|
def replace_path(path)
|
70
79
|
puts "replacing path #{path}"
|
80
|
+
unless @history # needed because safari strangly pops off outer most history on initialization
|
81
|
+
@history = @saved_history
|
82
|
+
@current_path = @saved_path
|
83
|
+
`ReactRouter.History.length = #{@saved_history_length}`
|
84
|
+
@history.on_state_change.call(:active) if @history.on_state_change
|
85
|
+
end
|
71
86
|
`window.history.replaceState({ path: path, history_id: #{@history.name}, history_length: ReactRouter.History.length}, '', path);`
|
72
87
|
@current_path = path
|
73
88
|
@history.notify_listeners(:replace)
|
@@ -115,7 +130,11 @@ class History
|
|
115
130
|
current_history = self.class.history
|
116
131
|
self.class.history = self
|
117
132
|
@starting_history_length = `ReactRouter.History.length` if current_history != self
|
118
|
-
|
133
|
+
if @name == "MainApp"
|
134
|
+
self.class.replace_path initial_path
|
135
|
+
else
|
136
|
+
self.class.push_path initial_path
|
137
|
+
end
|
119
138
|
@on_state_change.call(:active) if @on_state_change and current_history != self
|
120
139
|
self
|
121
140
|
end
|
@@ -127,8 +146,11 @@ class History
|
|
127
146
|
end
|
128
147
|
|
129
148
|
def notify_listeners(type)
|
130
|
-
puts "#{self}.notify_listeners(#{type}) listeners_count: #{@listeners.count}, path: #{self.class.current_path}"
|
149
|
+
puts "!! #{self}.notify_listeners(#{type}) listeners_count: #{@listeners.count}, path: #{self.class.current_path}"
|
131
150
|
@listeners.each { |listener| `listener.call(#{@location}, {path: #{self.class.current_path}, type: type})` }
|
151
|
+
rescue Exception => e
|
152
|
+
`debugger`
|
153
|
+
nil
|
132
154
|
end
|
133
155
|
|
134
156
|
|
@@ -164,7 +164,7 @@ module React
|
|
164
164
|
# override self.location to provide application specific location handlers
|
165
165
|
|
166
166
|
def location
|
167
|
-
(@location ||= History.new("MainApp")).activate.location
|
167
|
+
(@location ||= History.new("MainApp")).activate.location # must be called MainApp for now to avoid doing an extra state push (ugh)
|
168
168
|
end
|
169
169
|
|
170
170
|
after_mount do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: reactive-router
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam George
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|