Skip to content
This repository has been archived by the owner on Oct 19, 2018. It is now read-only.

uninitialized constant Hyperloop::Application #2

Open
barriehadfield opened this issue Feb 23, 2017 · 3 comments
Open

uninitialized constant Hyperloop::Application #2

barriehadfield opened this issue Feb 23, 2017 · 3 comments
Milestone

Comments

@barriehadfield
Copy link
Member

On page load after upgrading to overnight Gem 0.1.0

My store is:

class Discounter < Hyperloop::Store
   state discount: 30, scope: :class, reader: true
   state lucky_dip_taken: false, scope: :class, reader: true
  def lucky_dip!
    mutate.discount( state.discount + rand(-5..5) )
    mutate.lucky_dip_taken true
  end
end

@adamcreekroad
Copy link
Contributor

Yeah so this is a problem I brought up to @catmando ...that class level states are initialized on the Hyperloop::Application::Boot Operation, but there's the case the you don't have HyperOperations...
so for now you have to just mock up that code....

class HyperOperation
  class << self
    def on_dispatch(&block)
      receivers << block
    end

    def receivers
      @receivers ||= []
    end

    def dispatch(params = {})
      receivers.each do |receiver|
        receiver.call params
      end
    end
  end

  def dispatch(params = {})
    self.class.receivers.each do |receiver|
      receiver.call params
    end
  end
end

module Hyperloop
  class Application
    class Boot < HyperOperation
      include React::IsomorphicHelpers

      before_first_mount do
        dispatch
      end
    end
  end
end

Just stick that somewhere like your components.rb file and you should be good to do.

@barriehadfield
Copy link
Member Author

ok thanks @adamcreekroad lets leave this open until we resolve

@adamcreekroad
Copy link
Contributor

An update: make sure it is before require_tree './components'

@catmando catmando added this to the Release 0.15 milestone Nov 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants