Skip to content

Releases: hyperstack-org/hyperstack

alpha 1 milestone towards 1.0 release

14 Nov 06:28
Compare
Choose a tag to compare
  • all public module and class names updated and consistent - EXCEPT HyperModel
  • applications should now create a HyperComponent wrapper class (like ApplicationRecord)
  • public APIs are updated, consistent and stable
  • many previously deprecated features are now removed
  • state management is greatly simplified and 25X faster
  • all state and params are kept in regular ruby instance variables
  • automatic unmounting of every, after, and receives when owning components unmount
  • reactdom keyword which creates jQuery object from refs.
  • setmethod to interface between react ref, hyperstack dom, and promises.
  • you can use the render method inside of router classes instead of router.

Until alpha2 (or later) HyperModel still monkey patches ActiveRecord. Eventually HyperModel will be presented as include modules that you add to ApplicationRecord. But not yet.

To upgrade from Hyperloop 0.99:

  1. make sure you have resolved any deprecation notices first.
  2. update your Gemfile:
    2.1 use gem 'rails-hyperstack', '~> 1.0.alpha' instead of gem 'hyperloop'
    2.2 remove gem 'opal_hot_reloader' (its built in)
    2.3 update gem 'hyper-spec', '~> 1.0.alpha1.1'
    2.4 remove gem 'hyper-console' (not yet supported)
  3. rename the app/hyperloop directory to app/hyperstack
  4. change Hyperloop to Hyperstack in your policy files.
  5. update your hyperloop initializer file:
    5.1 change the module name from Hyperloop to Hyperstack
    5.2 remove the config.import 'reactrb/auto-import line.
    5.2 replace config.import 'opal-jquery', client_only: true with
    config.import 'hyperstack/component/jquery' if you use jquery.
    5.3 remove config.import 'react/ext/opal-jquery/element', client_only: true if present.
    5.4 if you are using the hot loader, replace config.import 'opal_hot_reloader', with
    config.import 'hyperstack/hotloader', client_only: true if Rails.env.development?
  6. update your application.js/rb file:
    6.1 replace //= require hyperloop-loader with //= require hyperstack-loader
    6.2 remove Opal.OpalHotReloader.$listen() - its built in now, and be configured in the hyperstack initializer.
  7. change the hot-loader entry in your Procfile to read hot-loader: bundle exec hyperstack-hotloader -d app/hyperstack
  8. in your routes file change Hyperstack to Hyperstack and hyperloop to hyperloop for example a basic routes file should look like this:
Rails.application.routes.draw do
  mount Hyperstack::Engine => '/hyperstack'
  get '/(*other)', to: 'hyperstack#app'
end
  1. add a migration - rails g migration DropHyperloopTables - with these contents:
  class DropHyperloopTables < ActiveRecord::Migration[5.2]
    def change
      drop_table :hyperstack_connections
      drop_table :hyperloop_connections
      drop_table :hyperstack_queued_messages
      drop_table :hyperloop_queued_messages
    end
  end
  1. add these definitions in your components directory:
  # app/hyperstack/components/_hyperloop_legacy_definitions.rb
  module Hyperloop
    class Component
      include Hyperstack::Component
      include Hyperstack::Legacy::Store
      param_accessor_style :legacy
    end
    class Router < Component
      def self.inherited(child)
        child.include Hyperstack::Router
      end
      class Component < Hyperloop::Component
        def self.inherited(child)
          child.include Hyperstack::Router::Helpers
        end
      end
    end
    class Store
      include Hyperstack::Legacy::Store
    end
  end
  module HyperRouter
    module ComponentMethods
      def self.included(base)
        base.include Hyperstack::Router::Helpers
      end
    end
  end
  1. so you can incrementally upgrade your components to Hyperstack syntax, you will also want to define an application component base class like this:
# app/hyperstack/components/hyper_component.rb
class HyperComponent
  include Hyperstack::Component
  include Hyperstack::State::Observer
end

Make sure you do a bundle install, and then rm -rf tmp/cache.

Your code should now run as before, and then as you wish you can change your component classes to inherit from your application HyperComponent base class instead of Hyperloop::Component