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

consistent name/semantics/syntax for all handlers  #243

Open
@catmando

Description

@catmando

there are three "modifiers" when a component is mounted:
on(...)
while_loading
after_error (proposed, but will probably be added in 1.0)

A proposal is to make these consistent like this:
on(...) where there are two (currently) special events: :loading, and :error.

class MyComponent < Hyperloop::Component
  render do
    DIV do
      ...
    end
    .on(:click) { alert('you clicked me!') }
    .on(:loading) { IMG(src: 'spinner.png') }
    .on(:error) { IMG(src: 'sad-face.png') }
  end
end

part two would be to add a new on callback which would apply these handlers to the component as a whole... so the above could be rewritten as:

class MyComponent < Hyperloop::Component
  render do
    DIV do
      ...
    end
  end
  on(:click) { alert('you clicked me!') }
  on(:loading) { IMG(src: 'spinner.png') }
  on(:error) { IMG(src: 'sad-face.png') }
end

or even

class MyComponent < Hyperloop::Component
  render(DIV) do
      ...
  end
  on(:click) { alert('you clicked me!') }
  on(:loading) { IMG(src: 'spinner.png') }
  on(:error) { IMG(src: 'sad-face.png') }
end

regardless of the specific syntax, we should allow these modifiers consistently to be used either inside a components render method using the .xxx notation, or to be applied to the whole component using a callback.

We need this because we have the render(ComponentName) do ... end syntax which precludes using the .xxx notation.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions