gordonbrander / spellcaster

Reactive signals UI library
MIT License
57 stars 2 forks source link

Update signature of `repeat()` #31

Closed gordonbrander closed 8 months ago

gordonbrander commented 8 months ago

Remove send function from signature, and switch argument order. The new function signature mirrors the signature of Lit's repeat.

Intended use:

repeat(states, MyView)

repeat(states, state => MyView2(state, send))

repeat(states, state => {
  const taggedSend = tag(send, state().id)
  return MyView3(state, taggedSend))
})

It's better to allow the parent view to use closure to pass down a send function if needed. This gives more flexibility to pass down a mapped or unmapped send function, or no send function at all.