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

Add an environment to Modifier #439

Open
cornerman opened this issue Sep 7, 2020 · 0 comments
Open

Add an environment to Modifier #439

cornerman opened this issue Sep 7, 2020 · 0 comments

Comments

@cornerman
Copy link
Member

cornerman commented Sep 7, 2020

We want to be able to build web components that depend on an environment without passing the environment through the whole application. The ideas basically boils down to having a type parameter for Modifier/VDomModifier like Modifier[-Env].

This allows the following:

case class MyEnv(state: State, api: Api)
...

val inputField: Modifier[MyEnv] = input(
  cls := "input-field",
  Modifier.access[MyEnv](env => value := env.state.initialValue),
  Modifier.access[MyEnv](env => onChange.value.useAsync(env.api.submitChange(_))
)

// Later you can use the input field just normally or at some point, you can decide to provide the environment:
val independentInputField: Modifier[Any] = inputField.provide(MyEnv(???, ???))

This will allows us to render Kleisli or ZIO with environments. Input and ideas are always welcome!

@cornerman cornerman added this to the 1.0 milestone Sep 9, 2020
@cornerman cornerman removed this from the 1.0 milestone Mar 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant