view_component_reflex 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6604db3319eb30b4cf0ac65502e46c3c1107094290b7ba2c9efda8c16735b250
4
- data.tar.gz: d644b0e76cc36cd6f969406569c4f28d32719e574a848bc360db0979398a0dbc
3
+ metadata.gz: af9ea0fbad8a65f59a333d8367315adb6a13bb52f7d6dcf35fccd8ad71b8de9c
4
+ data.tar.gz: 29846c963ffb334ac158b2658566cbb3a2cb1248e8e67febd0d0a034af134b54
5
5
  SHA512:
6
- metadata.gz: 3af567ec00951af7ba672cee153b30971f0c9ec679c148447c4e2379687e1af7592d3c23960135a9efd8d1d752bb9f482bcafd83731a88d60f6740175acce586
7
- data.tar.gz: a4a16cf03448c3251dd94714a98f269e06c983a7f1351aab7622a65a80a9ef3794c277fbd0cbb4b2ba7de91c16e4de4f4c4eff49dee4afa2f3a605d56980b14c
6
+ metadata.gz: 99478df0b1a5ffa4784aea880b7f757299a706e0ff35a2b6a692bfecbfe64b0cd483b730c115f0574f75f5566fb50770ce2e0d079e646e5ce01113b57adfe780
7
+ data.tar.gz: d6802a9810a10dbdef2e4f82ddfeb63e766973f1151b6f87799ebfac3513e446aaaf56649c6f31f2bf24a617ece938b539e3b317354189cee1ff99488db70650
data/README.md CHANGED
@@ -11,12 +11,15 @@ To add a reflex to your component, use the `reflex` method.
11
11
  ```ruby
12
12
  reflex :my_cool_reflex do
13
13
  # do stuff
14
+ refresh!
14
15
  end
15
16
  ```
16
17
 
17
18
  This will act as if you created a reflex with the method `my_cool_stuff`. To call this reflex, add `data-reflex="click->MyComponentReflex#my_cool_reflex"`, just like you're
18
19
  using stimulus reflex.
19
20
 
21
+ #####note: A reflex will not automatically re-render the component upon its completion. A component will re-render whenever the `set_state` or `refresh!` method is called.
22
+
20
23
  In addition to calling reflexes, there is a rudimentary state system. You can initialize component-local state with `initialize_state(obj)`, where `obj` is a hash.
21
24
 
22
25
  You can access state with the `state` helper. See the code below for an example. Calling `set_state` will set the state,
@@ -12,8 +12,7 @@ module ViewComponentReflex
12
12
  ViewComponentReflex::Engine.state_adapter.state(request, element.dataset[:key])
13
13
  end
14
14
 
15
- def set_state(new_state)
16
- ViewComponentReflex::Engine.state_adapter.set_state(self, element.dataset[:key], new_state)
15
+ def refresh!
17
16
  @channel.render_page_and_broadcast_morph(self, nil, {
18
17
  dataset: element.dataset.to_h,
19
18
  args: [],
@@ -25,6 +24,11 @@ module ViewComponentReflex
25
24
  })
26
25
  end
27
26
 
27
+ def set_state(new_state = {})
28
+ ViewComponentReflex::Engine.state_adapter.set_state(self, element.dataset[:key], new_state)
29
+ refresh!
30
+ end
31
+
28
32
  before_reflex do |reflex, *args|
29
33
  instance_exec(*args, &self.class.callbacks[self.method_name.to_sym]) if self.class.callbacks.include?(self.method_name.to_sym)
30
34
  throw :abort
@@ -1,3 +1,3 @@
1
1
  module ViewComponentReflex
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: view_component_reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua LeBlanc