Skip to content

Add at least some documentation to makeEmitter #2

@toastal

Description

@toastal

Is your change request related to a problem? Please describe.

makeEmitter
  :: forall a
   . ((a -> Effect Unit) -> Effect (Effect Unit))
  -> Emitter a
makeEmitter = coerce

This is a very confusing signature and definition for someone of novice-intermediate language experience. There's no examples, no test case, and what even is ((a -> Effect Unit) -> Effect (Effect Unit))? I think even adding a type alias like the type Canceler = Effect (Effect Unit) could help clarify what's going on. Not sure on the best solution, but currently I find it hard to understand.

Describe the solution you'd like
I started a thread on Discourse about requestAnimationFrame that has a useful, and probably popular use-case for makeEmitter in getting ticks for each frame. It could perhaps be common enough to have an Halogen.Subscriptions.{Common,Extra,Solutions,HTML,DOM,etc.} so the community can have a standardized solution for common problems -- especially for people looking for batteries-included, zephyr-will-clean-up-the-excess fix to "get sh*t done". Obviously you don't want to add DOM/HTML dependencies here, but it'd be a common dep in an application setting.

Additional context
Control.Plus.empty

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions