stimulus_reflex 1.0.0 → 1.0.1

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.

Potentially problematic release.


This version of stimulus_reflex might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 01c487c8dcbf81861bfb4a53e745ba41c5f5e9f33903b287b1a4dad85677fbcb
4
- data.tar.gz: 1192b6eb87371604649f4f63589664fbd954fbef93b1bd9114e4b717d6b0b57c
3
+ metadata.gz: 938d4a641bd8ab544990da39e9f5ac03d9c624d6cd88d2d0a0855654d00d2009
4
+ data.tar.gz: 398a90e77696a6477d49c8e338493a59db1a52cb678a3a0bd6bb9f6f1ca24266
5
5
  SHA512:
6
- metadata.gz: 3bd7af4f182254375a353839f561afa54927876065d3469bde34d3138c97ab14ebb50dc0587aaf1bc8db236df5e2c98ef71c6107e7def5a6582e13c84af0d6b8
7
- data.tar.gz: 1cfd21e9a2268c2a799ff1a77dc34dd46464b13feef9857fe76fd3bab64c05b4e5b26c993b6aed6959329b44e167d01d334ab368d8688194c89a4c2d522ca633
6
+ metadata.gz: 1e8f45b49f0635ad52d04550885e6485f324fc197b92a1664d5fae70fed0876788d79c74cd3f9b9189aa32e1b98c3ce720e40e387938b502b596d0edcbafdd97
7
+ data.tar.gz: ecc35de7b132a1b7e46b084b252b70fb73e24a5a0be783f4997b07fa9ebc4d483aeb162a0f426aac3d181718bf8f8d5b943436da096376f7c632f9ab8f82b522
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in stimulus_reflex.gemspec
6
6
  gemspec
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stimulus_reflex (1.0.0)
5
- actioncable (>= 5.2.1)
6
- actionpack (>= 5.2.1)
7
- cable_ready (>= 4.0.0)
4
+ stimulus_reflex (1.0.1)
5
+ actioncable (>= 5.2.3)
6
+ actionpack (>= 5.2.3)
7
+ cable_ready (>= 4.0.1)
8
8
  nokogiri
9
9
  rack
10
10
 
@@ -35,14 +35,14 @@ GEM
35
35
  tzinfo (~> 1.1)
36
36
  ast (2.4.0)
37
37
  builder (3.2.3)
38
- cable_ready (4.0.0)
38
+ cable_ready (4.0.1)
39
39
  activesupport (>= 5.0.0)
40
40
  concurrent-ruby (1.1.5)
41
41
  crass (1.0.4)
42
42
  erubi (1.8.0)
43
43
  i18n (1.6.0)
44
44
  concurrent-ruby (~> 1.0)
45
- jaro_winkler (1.5.2)
45
+ jaro_winkler (1.5.3)
46
46
  loofah (2.2.3)
47
47
  crass (~> 1.0.2)
48
48
  nokogiri (>= 1.5.9)
@@ -54,7 +54,6 @@ GEM
54
54
  parallel (1.17.0)
55
55
  parser (2.6.3.0)
56
56
  ast (~> 2.4.0)
57
- psych (3.1.0)
58
57
  rack (2.0.7)
59
58
  rack-test (1.1.0)
60
59
  rack (>= 1.0, < 3)
@@ -64,24 +63,26 @@ GEM
64
63
  rails-html-sanitizer (1.2.0)
65
64
  loofah (~> 2.2, >= 2.2.2)
66
65
  rainbow (3.0.0)
67
- rake (12.3.2)
68
- rubocop (0.67.2)
66
+ rake (12.3.3)
67
+ rubocop (0.72.0)
69
68
  jaro_winkler (~> 1.5.1)
70
69
  parallel (~> 1.10)
71
- parser (>= 2.5, != 2.5.1.1)
72
- psych (>= 3.1.0)
70
+ parser (>= 2.6)
73
71
  rainbow (>= 2.2.2, < 4.0)
74
72
  ruby-progressbar (~> 1.7)
75
- unicode-display_width (>= 1.4.0, < 1.6)
76
- ruby-progressbar (1.10.0)
77
- standard (0.0.39)
78
- rubocop (~> 0.67.1)
73
+ unicode-display_width (>= 1.4.0, < 1.7)
74
+ rubocop-performance (1.4.1)
75
+ rubocop (>= 0.71.0)
76
+ ruby-progressbar (1.10.1)
77
+ standard (0.1.2)
78
+ rubocop (~> 0.72.0)
79
+ rubocop-performance (~> 1.4.0)
79
80
  standardrb (1.0.0)
80
81
  standard
81
82
  thread_safe (0.3.6)
82
83
  tzinfo (1.2.5)
83
84
  thread_safe (~> 0.1)
84
- unicode-display_width (1.5.0)
85
+ unicode-display_width (1.6.0)
85
86
  websocket-driver (0.7.1)
86
87
  websocket-extensions (>= 0.1.0)
87
88
  websocket-extensions (0.1.4)
data/README.md CHANGED
@@ -1,23 +1,28 @@
1
- [![Lines of Code](http://img.shields.io/badge/lines_of_code-120-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
1
+ [![Lines of Code](http://img.shields.io/badge/lines_of_code-171-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
2
2
  [![Maintainability](https://api.codeclimate.com/v1/badges/2b24fdbd1ae37a24bedb/maintainability)](https://codeclimate.com/github/hopsoft/stimulus_reflex/maintainability)
3
- [![Ruby Dependency Graph](https://img.shields.io/badge/deps-ruby-informational.svg?style=flat)](https://github.com/hopsoft/stimulus_reflex/blob/master/gem_graph.svg)
4
3
 
5
4
  # StimulusReflex
6
5
 
7
- #### Build rich interactive UIs with standard Rails... no need for a complex frontend framework
6
+ ### Reactive user interfaces with Rails and Stimulus
8
7
 
9
- This library provides functionality similar to [Phoenix LiveView](https://youtu.be/Z2DU0qLfPIY?t=670) for Rails applications.
8
+ #### No need for a complex frontend framework
10
9
 
11
- Add the benefits of single page apps (SPA) to server rendered Rails/Stimulus projects with a minimal investment of time, resources, and complexity.
12
- _The goal is to provide 80% of the benefits of SPAs with 20% of the typical effort._
10
+ This project aims to support the building of [Single Page Applications (SPAs)](https://en.wikipedia.org/wiki/Single-page_application)
11
+ with standard Rails tooling. Think server rendered HTML, Stimulus, Turbolinks, etc...
13
12
 
14
- 1. Use [ActionCable](https://edgeguides.rubyonrails.org/action_cable_overview.html) to invoke a method on the server.
15
- 1. Watch the page automatically render updates via fast [DOM diffing](https://github.com/patrick-steele-idem/morphdom).
13
+ Inspired by [Phoenix LiveView](https://youtu.be/Z2DU0qLfPIY?t=670). 🙌
14
+
15
+ ## How it Works
16
+
17
+ 1. Use [ActionCable](https://edgeguides.rubyonrails.org/action_cable_overview.html) to invoke a method on the server
18
+ 1. Watch the page automatically render updates via fast [DOM diffing](https://github.com/patrick-steele-idem/morphdom)
16
19
  1. That's it...
17
20
 
18
- - Yes, it really is that simple. Just write your HTML page.
19
- - If you hit refresh, that works, too.
20
- - There's no hidden gotcha.
21
+ __Yes, it really is that simple.__
22
+ Just create a server rendered HTML page and send RPC calls to the server via web socket.
23
+ There are no hidden gotchas.
24
+
25
+ ![How it Works](https://raw.githubusercontent.com/hopsoft/stimulus_reflex/master/docs/diagram.png)
21
26
 
22
27
  ## Setup
23
28
 
@@ -33,7 +38,7 @@ yarn add stimulus_reflex
33
38
  gem "stimulus_reflex"
34
39
  ```
35
40
 
36
- ## Usage
41
+ ## Basic Usage
37
42
 
38
43
  ### app/views/pages/example.html.erb
39
44
 
@@ -77,15 +82,39 @@ end
77
82
 
78
83
  The following happens after the `StimulusReflex::Reflex` method call finishes.
79
84
 
80
- 1. The page that triggered the reflex is re-rerendered. _Note that instance variables created in the reflex are available to both the controller and view templates._
85
+ 1. The page that triggered the reflex is re-rerendered. _Instance variables created in the reflex are available to both the controller and view templates._
81
86
  2. The re-rendered HTML is sent to the client over the ActionCable socket.
82
87
  3. The page is updated via fast DOM diffing courtesy of morphdom. _While future versions of StimulusReflex might support more granular updates, today the entire body is re-rendered and sent over the socket._
83
88
 
89
+ ## Advanced Usage
90
+
84
91
  ### ActionCable
85
92
 
86
- StimulusReflex will use the Rails' ActionCable defaults `window.App` and `App.cable` if they exist.
87
- If these defaults do not exist, StimulusReflex will attempt to establish a new socket connection.
93
+ StimulusReflex will use the ActionCable defaults of `window.App` and `App.cable` if they exist.
94
+ If these defaults do not exist, StimulusReflex will establish a new socket connection.
95
+
96
+ ### ActionCable Rooms
97
+
98
+ You may find the need to restrict notifications to a specific room.
99
+ This can be accomplished by setting the `data-room` attribute on the StimulusController element.
100
+
101
+ ```
102
+ <a href="#" data-controller="example" data-action="click->example#increment" data-room="12345">
103
+ ```
104
+
105
+ ### Render Delay
106
+
107
+ An attempt is made to reduce repaint/reflow jitter when users trigger lots of updates.
108
+
109
+ You can control how long to wait _(think debounce)_ prior to updating the page.
110
+ Simply set the `renderDelay` _(milliseconds)_ option when registering the controller.
88
111
 
89
- ## JavaScript Development
112
+ ```javascript
113
+ export default class extends Controller {
114
+ connect() {
115
+ StimulusReflex.register(this, {renderDelay: 200});
116
+ }
117
+ }
118
+ ```
90
119
 
91
- The JavaScript library is hosted at: https://github.com/hopsoft/stimulus_reflex_client
120
+ The default value is `25`.
@@ -9,10 +9,12 @@ class StimulusReflex::Channel < ActionCable::Channel::Base
9
9
  include CableReady::Broadcaster
10
10
 
11
11
  def stream_name
12
- ids = connection.identifiers.map { |identifier|
13
- send(identifier).try(:id)
14
- }
15
- "#{channel_name}#{ids.join ":"}"
12
+ ids = connection.identifiers.map { |identifier| send(identifier).try(:id) }
13
+ [
14
+ params[:channel],
15
+ params[:room],
16
+ ids.select(&:present?).join(";"),
17
+ ].select(&:present?).join(":")
16
18
  end
17
19
 
18
20
  def subscribed
@@ -1,3 +1,3 @@
1
1
  module StimulusReflex
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stimulus_reflex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Hopkins
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-08-09 00:00:00.000000000 Z
12
+ date: 2019-08-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
@@ -45,42 +45,42 @@ dependencies:
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
- version: 5.2.1
48
+ version: 5.2.3
49
49
  type: :runtime
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 5.2.1
55
+ version: 5.2.3
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: actionpack
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - ">="
61
61
  - !ruby/object:Gem::Version
62
- version: 5.2.1
62
+ version: 5.2.3
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 5.2.1
69
+ version: 5.2.3
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: cable_ready
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
- version: 4.0.0
76
+ version: 4.0.1
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
- version: 4.0.0
83
+ version: 4.0.1
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: bundler
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -137,7 +137,6 @@ files:
137
137
  - README.md
138
138
  - Rakefile
139
139
  - bin/console
140
- - bin/deps
141
140
  - bin/setup
142
141
  - bin/standardize
143
142
  - lib/stimulus_reflex.rb
data/bin/deps DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- bundle viz --version --format svg --without development test