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

I'm almost OK with this #1

Open
kswope opened this issue Jun 24, 2021 · 1 comment
Open

I'm almost OK with this #1

kswope opened this issue Jun 24, 2021 · 1 comment

Comments

@kswope
Copy link

kswope commented Jun 24, 2021

It almost encourages a Service layer architecture where Rescript is your "app", and the .svelte files are just the messy outer interface, which will always be chaotic because you've got JS/CSS/HTML/preprocessors/postprocessors/bundlers/etc. reference Rails is Not Your Application

Now the part that isn't type-checked is the boundary between your display layer and its service layer. You can keep this interface to a minimum by using subscribe() to get data out and simple functions with simple arg types to get data in, like you did. An extra benefit of this discipline is that you can cleanly test it separate from the interface.

If rescript is ever an option is .svelte files then it will be easy conversion.

I tried using typescript in the svelte files and I'm not sure it got me anywhere. Every file needed a .d.ts file and chances are you might not reuse those definitions often so it might end up being one function call per definition, which just means you moved your bugs to the .d.ts files.

And typescript looks awful

  let updateName: svelte.JSX.FormEventHandler<HTMLInputElement> = (e) => {
    update(e.currentTarget.value)
  }
</script>

<main>
  <input on:input={updateName} value={name} placeholder="enter your name" />
  <p>Hello {name || "stranger"}!</p>
</main>

@arafatamim
Copy link

I wonder how hard it would be to add official ReScript integration in the toolchain.

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

No branches or pull requests

2 participants