isomorfeus-redux 4.0.4 → 4.0.5
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/README.md +6 -5
- data/lib/isomorfeus/promise.rb +1 -2
- data/lib/isomorfeus/redux_config.rb +19 -0
- data/lib/isomorfeus-redux.rb +5 -1
- data/lib/redux/reducers.rb +21 -0
- data/lib/redux/store.rb +2 -4
- data/lib/redux/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49006acd13e7f948dbb946c3b268efce6e0aa6da59737c38bbfefe0268382f99
|
4
|
+
data.tar.gz: 537e3571716389f6a76eb003301f5d34fab219453ba87d49f133bd6b0b23128f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae672f889977318b8e4b84f680a79899ddd0fe8d71d8b600451429f0ad3def04dd59ef030e78d3970dfa1ad6fbe77a7185b1381d280fb2d1afb6065a5b1235ba
|
7
|
+
data.tar.gz: 58790b372dc6d6ad25a4f28d065559859392c5c9da0930b9e645d37373a74edb219fe0fed5c15ee35b7ad99359e482550f4e46552b370c59a4a4ed9cf7d5bbe5
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ At the [Isomorfeus Framework Project](http://isomorfeus.com)
|
|
7
7
|
|
8
8
|
## Versioning
|
9
9
|
isomorfeus-redux version follows the Redux version which features and API it implements.
|
10
|
-
Isomorfeus-redux 4.0.x implements features and the API of Redux 4.0 and should be used with
|
10
|
+
Isomorfeus-redux 4.0.x implements features and the API of Redux 4.0 and should be used with Redux 4.0
|
11
11
|
|
12
12
|
## Installation
|
13
13
|
To install redux with the matching version:
|
@@ -27,14 +27,14 @@ require 'isomorfeus-redux'
|
|
27
27
|
### Dependencies
|
28
28
|
|
29
29
|
For full functionality the following are required:
|
30
|
-
- [Opal ES6 import export](https://github.com/opal/opal/pull/
|
30
|
+
- [Opal ES6 import export](https://github.com/opal/opal/pull/1976)
|
31
31
|
- [Opal Webpack Loader](https://github.com/janbiedermann/opal-webpack-loader)
|
32
32
|
- [Opal Autoloader](https://github.com/janbiedermann/opal-autoloader)
|
33
33
|
|
34
34
|
For the Gemfile:
|
35
35
|
```ruby
|
36
|
-
gem 'opal', github: 'janbiedermann/opal', branch: '
|
37
|
-
gem 'opal-webpack-loader', '~> 0.
|
36
|
+
gem 'opal', github: 'janbiedermann/opal', branch: 'es6_modules_1_1'
|
37
|
+
gem 'opal-webpack-loader', '~> 0.9.1'
|
38
38
|
gem 'opal-autoloader', '~> 0.0.3'
|
39
39
|
```
|
40
40
|
|
@@ -92,6 +92,7 @@ To get the native store from within Javascript context:
|
|
92
92
|
```javascript
|
93
93
|
Opal.Isomorfeus.store.native
|
94
94
|
```
|
95
|
+
|
95
96
|
### Other Rubyfications
|
96
97
|
- `dispatch` accepts a Ruby Hash
|
97
98
|
- `get_state` returns a Ruby Hash
|
@@ -102,7 +103,7 @@ Isomorfeus.store.subscribe do
|
|
102
103
|
end
|
103
104
|
```
|
104
105
|
### Setup
|
105
|
-
|
106
|
+
If isomorfeus-redux is used in isolation, these methods can be used:
|
106
107
|
```ruby
|
107
108
|
Redux::Store.add_middleware(middleware) # middleware must be Javascript function
|
108
109
|
Redux::Store.init! # initializes the global store
|
data/lib/isomorfeus/promise.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
# taken from https://github.com/ruby-hyperloop/
|
2
|
-
# TODO: This is used only server side and may be used by others too and should be a separate gem maybe
|
1
|
+
# taken from https://github.com/ruby-hyperloop/hyper-operation/blob/edge/lib/hyper-operation/promise.rb
|
3
2
|
|
4
3
|
class Promise
|
5
4
|
def self.value(value)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Isomorfeus
|
2
|
+
class << self
|
3
|
+
attr_reader :store_initialized
|
4
|
+
attr_reader :store
|
5
|
+
|
6
|
+
def init_store
|
7
|
+
return if store_initialized
|
8
|
+
@store_initialized = true
|
9
|
+
force_init_store!
|
10
|
+
end
|
11
|
+
|
12
|
+
def force_init_store!
|
13
|
+
# at least one reducer must have been added at this stage
|
14
|
+
# this happened in isomorfeus-react.rb, where the component reducers were added
|
15
|
+
@store = Redux::Store.init!
|
16
|
+
`Opal.Isomorfeus.store = #@store`
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/isomorfeus-redux.rb
CHANGED
@@ -4,7 +4,11 @@ if RUBY_ENGINE == 'opal'
|
|
4
4
|
require 'redux/version'
|
5
5
|
require 'redux'
|
6
6
|
require 'redux/store'
|
7
|
-
|
7
|
+
require 'redux/reducers'
|
8
|
+
require 'isomorfeus/redux_config'
|
9
|
+
|
10
|
+
Redux::Reducers::add_application_reducers_to_store
|
11
|
+
Isomorfeus.init_store
|
8
12
|
else
|
9
13
|
require 'opal'
|
10
14
|
require 'isomorfeus/promise'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Redux
|
2
|
+
module Reducers
|
3
|
+
def self.add_application_reducers_to_store
|
4
|
+
unless @_application_reducers_added
|
5
|
+
@_application_reducers_added = true
|
6
|
+
app_reducer = Redux.create_reducer do |prev_state, action|
|
7
|
+
case action[:type]
|
8
|
+
when 'APPLICATION_STATE'
|
9
|
+
new_state = {}.merge!(prev_state) # make a copy of state
|
10
|
+
new_state.merge!(action[:name] => action[:value])
|
11
|
+
new_state
|
12
|
+
else
|
13
|
+
prev_state
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
Redux::Store.add_reducers(application_state: app_reducer)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/redux/store.rb
CHANGED
@@ -94,15 +94,13 @@ module Redux
|
|
94
94
|
end
|
95
95
|
|
96
96
|
def add_reducer(reducer)
|
97
|
-
self.class.reducers
|
98
|
-
next_reducer = Redux.combine_reducers(
|
97
|
+
self.class.reducers.merge!(reducer)
|
98
|
+
next_reducer = Redux.combine_reducers(self.class.reducers)
|
99
99
|
self.replace_reducer = next_reducer
|
100
100
|
end
|
101
101
|
|
102
102
|
def add_reducers(new_reducers)
|
103
|
-
|
104
103
|
self.class.reducers.merge!(new_reducers)
|
105
|
-
|
106
104
|
next_reducer = Redux.combine_reducers(self.class.reducers)
|
107
105
|
replace_reducer(next_reducer)
|
108
106
|
end
|
data/lib/redux/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-redux
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -34,7 +34,9 @@ files:
|
|
34
34
|
- README.md
|
35
35
|
- lib/isomorfeus-redux.rb
|
36
36
|
- lib/isomorfeus/promise.rb
|
37
|
+
- lib/isomorfeus/redux_config.rb
|
37
38
|
- lib/redux.rb
|
39
|
+
- lib/redux/reducers.rb
|
38
40
|
- lib/redux/store.rb
|
39
41
|
- lib/redux/version.rb
|
40
42
|
homepage: http://isomorfeus.com
|