-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(router):
until
directive breaks haunted effects
The haunted state is updated twice in the same update-render-loop, causing the scheduler to miss running the effects upon component initialization.
- Loading branch information
1 parent
958dfa9
commit 951e886
Showing
3 changed files
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,26 @@ | ||
import { | ||
nothing, html | ||
nothing, | ||
html | ||
} from 'lit-html'; | ||
import { until } from 'lit-html/directives/until'; | ||
import { | ||
component, useMemo | ||
component, | ||
useMemo | ||
} from 'haunted'; | ||
import { | ||
useRoutes | ||
} from './lib/use-routes'; | ||
import { useRoutes } from './lib/use-routes'; | ||
import { useRouteEvents } from './lib/use-route-events'; | ||
import { usePromise } from '@neovici/cosmoz-utils/lib/hooks/use-promise'; | ||
|
||
const Router = function ({ | ||
routes | ||
}) { | ||
const route = useRoutes(routes), | ||
result = useMemo(() => route ? route.handle() : undefined, [route]), | ||
renderResult = useMemo(() => Promise.resolve(result).catch(() => nothing), [result]); | ||
renderResult = useMemo(() => Promise.resolve(result).catch(() => nothing), [result]), | ||
[output] = usePromise(renderResult); | ||
|
||
useRouteEvents(route, result, this); | ||
|
||
return html`${until(renderResult, nothing)}`; | ||
return html`${output || nothing}`; | ||
}; | ||
|
||
customElements.define('cosmoz-page-router', component(Router)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters