Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add examples of lazy & memoized#747

Merged
thomashoneyman merged 3 commits intopurescript-halogen:masterpurescript-halogen/purescript-halogen:masterfrom
thomashoneyman:memoized-exampleCopy head branch name to clipboard
Apr 15, 2021
Merged

Add examples of lazy & memoized#747
thomashoneyman merged 3 commits intopurescript-halogen:masterpurescript-halogen/purescript-halogen:masterfrom
thomashoneyman:memoized-exampleCopy head branch name to clipboard

Conversation

@thomashoneyman
Copy link
Member

This PR adds examples for the lazy and memoized functions. The example works by displaying three results of calling a very poor fibonnaci implementation, with an extra button to toggle the background color of the example. Toggling the background color without memoization leads to extremely slow renders.

The first example re-renders any time the state changes, like normal Halogen, and it's quite slow. The second example uses memoized with eq, and it's quite slow because of #742 (but is fixed in #743). The third example uses lazy and is quite fast.

Here's a demonstration of this example running against master:

master.mov

Notably, the memoized example is still very slow. But if I run this example against the fix-memoized branch used in #743 the result is what we'd expect:

fix-memoized.mov

@thomashoneyman thomashoneyman mentioned this pull request Apr 9, 2021
@thomashoneyman thomashoneyman merged commit d424510 into purescript-halogen:master Apr 15, 2021
@thomashoneyman thomashoneyman deleted the memoized-example branch April 15, 2021 15:06
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.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.