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

Some problem when follow this tuto. #7

Open
zw963 opened this issue Jul 30, 2017 · 1 comment
Open

Some problem when follow this tuto. #7

zw963 opened this issue Jul 30, 2017 · 1 comment

Comments

@zw963
Copy link

zw963 commented Jul 30, 2017

Following just the summarize discuss in gitter:

Following is toto error:

  • get '/(*other)', to: 'hyperloop#app', which introduce in Chapter 7, should mention in Chapter 1, other, rails route not worked, I do this myself when follow this tuto, but others maybe not.

  • after rails g hyperloop:install, and then copy application_record.rb into app/hyperloop/models, that not work, uninitialized constant ApplicationRecord, the solution is: add config.import 'models/application_record' into config/initializers/hyperloop.rb, and rm tmp/cache, then worked.
    this step is done in this project, but when follow tuto, no where told us.

Follow is some advice for hyperloop

Following usage i think is error-prone.
EditItem(todo: params.todo).on(:save, :cancel) { mutate.editing false }
In most case, :save, :cancel should be browser internal event,
If we use a event like this but name conflict with this, what happen?
and, use param to define a event is very strange for me.

I think a better idea is: (two selection)

  • Not use on method, not conflict with browser event, you just hope yield
    one behavior only, use a name other than on is better, or, just simple:
# replace EditItem(todo: params.todo).on(:save, :cancel) { mutate.editing false }
# with

EditItem(
        todo:      params.todo,
        on_save:   proc { mutate.editing false },
        on_cancel: proc { mutate.editing false }
      )

# and invoke it like this:
params.on_save.call
  • Not use param to declare a event. e.g.
def event(name)
  # detect all browser internal support event name, if conflict, raise a error.
  param name, type: Proc
end
event :on_save

I think first solution is better, because params.on_save is just like usual param,
it just use logic instead of a variable.

@zw963
Copy link
Author

zw963 commented Aug 18, 2017

Hi, @catmando , I try to follow Not use on method mentioned in issue, but that not work.

Please see this commit, when I change back to use old usage, it worked.

zw963/hyperloop_todo_example@52e3ede

So, I think there exist some weird hack for this.

Could you please explain why it not work before this commit?

Thanks

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

1 participant