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 HtmlTag#withSelf, restore debounce example #155

Merged
merged 2 commits into from
Jan 22, 2023
Merged

Add HtmlTag#withSelf, restore debounce example #155

merged 2 commits into from
Jan 22, 2023

Conversation

armanbilge
Copy link
Owner

Closes #132.

docs/time.md Outdated
Comment on lines 92 to 93
input { self =>
input { (self: fs2.dom.HtmlInputElement[IO]) => // FIXME compiler bug
onInput --> (_.evalMap(_ => self.value.get).through(emailCh.sendAll))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is extremely annoying. Another workaround is to do:

input { self =>
  Tuple1(onInput --> (_.evalMap(_ => self.value.get).through(emailCh.sendAll)))
}

I'm going to try and minimize and report a compiler bug.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2chilled
2chilled previously approved these changes Jan 21, 2023
Copy link
Collaborator

@2chilled 2chilled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there's still work to do in regards to implementing overloads soundly, even in Scala 3. To this day, I've always avoided them without missing too much.

@armanbilge
Copy link
Owner Author

To this day, I've always avoided them without missing too much.

Yes, that is often good practice. Do you think we should do that here? We can add it as an alternative API e.g.

input.withSelf { self =>
  onInput --> (_.evalMap(_ => self.value.get).through(emailCh.sendAll))
}

I think Laminar might call it withContext.

@2chilled
Copy link
Collaborator

I'd absolutely prefer that, yes. These types of bugs are super annoying, especially for non expert Scala users. In my experience it's best to even disable all nasty features that can be somehow disabled. At work, we use the strictest scalac 2 settings together with nearly all of https://www.wartremover.org/, and everyone is super happy with that. Furthermore, we still avoid Scala 3 there, because there are a bunch of strict flags not implemented (yet?).

@2chilled
Copy link
Collaborator

Ah and withSelf is a good name in my subjective eyes :)

@armanbilge
Copy link
Owner Author

Great, I'll add that!

because there are a bunch of strict flags not implemented (yet?).

Good news, many new strict flags are arriving in Scala 3.3.0 :)

@armanbilge armanbilge changed the title Restore debounce example Add HtmlTag#withSelf, restore debounce example Jan 21, 2023
def apply[M](mkModifier: E => M)(using M: Modifier[F, E, M]): Resource[F, E] =
def withSelf[M](mkModifier: E => M)(using M: Modifier[F, E, M]): Resource[F, E] =
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not to second guess 😅 maybe another option is fromSelf. But withSelf is good. I think 😅

input { (self: fs2.dom.HtmlInputElement[IO]) => // FIXME compiler bug
input.withSelf { self =>
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, overloads are bad 😓

@armanbilge armanbilge dismissed 2chilled’s stale review January 21, 2023 20:22

trying a different solution

@armanbilge armanbilge merged commit 873ede1 into main Jan 22, 2023
@armanbilge armanbilge deleted the pr/i132 branch January 22, 2023 16:06
@armanbilge
Copy link
Owner Author

Seems like there's still work to do in regards to implementing overloads soundly, even in Scala 3.

Yeah, seems like what I was trying to do here was an unsupported behavior according to scala/scala3#16737 (comment) 😅

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.

Restore debounce example
2 participants