Skip to content

Add HtmlTag#withSelf, restore debounce example#155

Merged
armanbilge merged 2 commits intomainfrom
pr/i132
Jan 22, 2023
Merged

Add HtmlTag#withSelf, restore debounce example#155
armanbilge merged 2 commits intomainfrom
pr/i132

Conversation

@armanbilge
Copy link
Copy Markdown
Owner

Closes #132.

Comment thread docs/time.md
Comment on lines 92 to 93
label("Your email: "),
input { self =>
input { (self: fs2.dom.HtmlInputElement[IO]) => // FIXME compiler bug
onInput --> (_.evalMap(_ => self.value.get).through(emailCh.sendAll))
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor

@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
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Contributor

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

@armanbilge
Copy link
Copy Markdown
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
build.toResource.flatTap(M.modify(modifier, _))

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
Copy Markdown
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 😅

Comment thread docs/time.md Outdated
span(
label("Your email: "),
input { (self: fs2.dom.HtmlInputElement[IO]) => // FIXME compiler bug
input.withSelf { self =>
Copy link
Copy Markdown
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 requested a review from 2chilled January 21, 2023 20:23
@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
Copy Markdown
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