Skip to content

Create a lazy signal that employs an Effect #1

Description

@bbarker

I'd like to have something like a signal that reads the current date:

dateTimeWidg :: Widget HTML DateTime
dateTimeWidg = liftEffect nowDateTime

dateTimeSig :: Signal HTML DateTime
dateTimeSig = sig initDate
  where
    sig dt = step dt do
      newDt <- dateTimeWidg
      pure $ sig newDt

The widget seems fine, however, the signal creates an infinite (eagerly evaluated) loop, since dateTimWidg returns immediately.

Ideally, there would be a way to have dateTimeSig only queried when other signals at the same level fire. The particular goal here is that I have user's inputting data to records, but this particular field of the record should be automatically timestamped by the app.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghelp wantedExtra attention is needed

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions