Skip to content

Commit 6c34ce1

Browse files
authored
Update upgrade-from-hyperloop.md
1 parent a9ef2e0 commit 6c34ce1

File tree

1 file changed

+82
-4
lines changed

1 file changed

+82
-4
lines changed

upgrade-from-hyperloop.md

Lines changed: 82 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,20 @@ gem 'rails-hyperstack', '~> 1.0.alpha1.5'
77
gem 'hyper-spec', '~> 1.0.alpha1.5' # if using hyper-spec
88
```
99

10-
remove any references to hotloader stuff.
10+
remove any references to hotloader stuff from the gemfile, as well as opal-jquery, and hyper-react
11+
(these will all be brought in as needed by rails-hyperstack)
12+
1113

1214
### 2. Move `app/hyperloop` directory to `app/hyperstack`
1315

1416
the internal directories can remain (i.e. components, models, etc)
1517

18+
### 2. Rename `app/hyperstack/component.rb` file.
19+
20+
rename it to component.rbx it is no longer used, but you might want to keep it just in case instead of deleting.
21+
22+
Renaming it to .rbx will effectively remove it, without deleting it.
23+
1624
### 3. Double check `application_record.rb` files are correct.
1725

1826
Your main definition of `ApplicationRecord` should be in `app/hyperstack/models/application_record.rb`
@@ -45,18 +53,20 @@ class HyperComponent
4553
end
4654
```
4755

48-
Now global search and replace all references to `Hyperloop::Component` to `HyperComponent`
56+
Now global search and replace all references in the `app/hyperstack/components` directory from `Hyperloop::Component` to `HyperComponent`
4957

5058
### 5. Update app/assets/javascript/application.js
5159

5260
The last lines of `app/assets/javascripts/application.js` should look like this:
5361

5462
```javascript
5563
//= require hyperstack-loader
56-
//= require_tree .
64+
//= require_tree .
5765
```
5866

59-
Note: remove any lines mentioning hotloader.
67+
If you are not using require_tree, then the hyperstack-loader require should be towards the bottom, you might have to play with the position to get it right, but basically it should be the last thing required before you get into your application specific requires that are in the `app/assets/javascript` directory.
68+
69+
remove any references to react, react_ujs, hotloader, opal, opal-jquery, and hyperloop-loader, this is all now handled by hyperstack-loader
6070

6171
### 6. Update items related to Hotloader
6272

@@ -80,17 +90,85 @@ remove any other references to hotloader in the initializer, and in `app/assets
8090

8191
Rename `config/initializers/hyperloop.rb` to `config/initializers/hyperstack.rb`
8292

93+
The initializer will look like this... comment/uncomment as needed:
94+
95+
```ruby
96+
# comment next line out if NOT using webpacker
97+
Hyperstack.cancel_import 'react/react-source-browser' # bring your own React and ReactRouter via Yarn/Webpacker
98+
# uncomment next line if using hotloader
99+
# Hyperstack.import 'hyperstack/hotloader', client_only: true if Rails.env.development?
100+
# set the component base class
101+
102+
Hyperstack.component_base_class = 'HyperComponent' # i.e. 'ApplicationComponent'
103+
104+
# prerendering is default :off, you should wait until your
105+
# application is relatively well debugged before turning on.
106+
107+
Hyperstack.prerendering = :off # or :on
108+
109+
# transport controls how push (websocket) communications are
110+
# implemented. The default is :action_cable.
111+
# Other possibilities are :pusher (see www.pusher.com) or
112+
# :simple_poller which is sometimes handy during system debug.
113+
114+
Hyperstack.transport = :action_cable # or :none, :pusher, :simple_poller
115+
116+
# add this line if you need jQuery
117+
Hyperstack.import 'hyperstack/component/jquery', client_only: true
118+
119+
# change definition of on_error to control how errors such as validation
120+
# exceptions are reported on the server
121+
module Hyperstack
122+
def self.on_error(operation, err, params, formatted_error_message)
123+
::Rails.logger.debug(
124+
"#{formatted_error_message}\n\n" +
125+
Pastel.new.red(
126+
'To further investigate you may want to add a debugging '\
127+
'breakpoint to the on_error method in config/initializers/hyperstack.rb'
128+
)
129+
)
130+
end
131+
end if Rails.env.development?
132+
```
133+
83134
### 8. Change Element to jQ
84135

85136
If you are using jQuery, you will have things like `Element['#some-id'].focus()` etc.
86137
These need to change to `jQ[...].focus()` etc.
87138

139+
Use CASE SENSITIVE global search and replace.
140+
141+
88142
### 9. `IsomorphicHelpers` changes to `Hyperstack::Component::IsomorphicHelpers`
89143

90144
search and replace...
91145

146+
### 10. Stores
147+
148+
To use legacy store behavior you can include the `Hyperstack::Legacy::Store` mixin, in your stores.
149+
150+
You do not need to subclass the stores. However if you have a lot of stores, you could create a base class like this:
151+
152+
```ruby
153+
# app/hyperstack/stores/hyper_store.rb
154+
class HyperStore
155+
include Hyperstack::Legacy::Store
156+
end
157+
```
158+
159+
and then subclass off of Hyperstore.
160+
161+
You will also need to add this to your Gemfile:
162+
163+
```ruby
164+
gem 'hyper-store`, '~> 1.0.alpha1.5'
165+
```
166+
92167
### 10. Change name of Hyperloop::... to Hyperstack::
93168
169+
Hyperloop::Operation -> Hyperstack::Operation
170+
Hyperloop::Store ->
171+
94172
If at this point you have other classes and methods under the `Hyperloop` namespace, you will have to find
95173
the equivilent class or method under Hyperstack. Its going to be a case by case basis. Let us know if you need help, and we can
96174
add each case to this document.

0 commit comments

Comments
 (0)