Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: Introduces remember and builds stable eventHandlers on top of it. #1267

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rjrjr
Copy link
Contributor

@rjrjr rjrjr commented Feb 21, 2025

No description provided.

@rjrjr rjrjr force-pushed the ray/remember-event-handler branch 6 times, most recently from d4cdaa3 to a137249 Compare February 25, 2025 00:34
@rjrjr
Copy link
Contributor Author

rjrjr commented Feb 25, 2025

Looking promising:

  override fun eventHandler(
    name: String,
    update: WorkflowAction<
      @UnsafeVariance PropsT,
      StateT,
      @UnsafeVariance OutputT
      >.Updater.() -> Unit
  ): () -> Unit {
    val handler = { actionSink.send(action("eventHandler:$name", update)) }
    return if (stableEventHandlers) {
      class Box0 {
        lateinit var delegate: () -> Unit
        fun fire() = delegate()
      }

      val box = remember("stableEventHandler:$name") { Box0() }
      box.delegate = handler
      box::fire
    } else {
      handler
    }
  }

@rjrjr rjrjr force-pushed the ray/remember-event-handler branch 6 times, most recently from 95498e2 to fec7178 Compare February 26, 2025 01:40
@rjrjr rjrjr force-pushed the ray/remember-event-handler branch from fc02943 to 1f63015 Compare March 1, 2025 04:42
@rjrjr rjrjr changed the title remember event handler wip: Introduces remember and builds stable eventHandlers on top of it. Mar 1, 2025
@rjrjr rjrjr force-pushed the ray/remember-event-handler branch 2 times, most recently from 77672ac to 7348024 Compare March 3, 2025 20:52
@rjrjr rjrjr force-pushed the ray/remember-event-handler branch from 7348024 to 9a11110 Compare March 7, 2025 01:06
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants