basic functionality
This commit is contained in:
parent
27769a69d9
commit
1053a316fc
@ -9,6 +9,8 @@ import dataclasses
|
|||||||
import functools
|
import functools
|
||||||
import inspect
|
import inspect
|
||||||
import io
|
import io
|
||||||
|
import multiprocess
|
||||||
|
from pathos import multiprocessing, pools
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import sys
|
import sys
|
||||||
@ -177,7 +179,7 @@ class OverlayFragment(Fragment):
|
|||||||
class UncompiledPage:
|
class UncompiledPage:
|
||||||
"""An uncompiled page."""
|
"""An uncompiled page."""
|
||||||
|
|
||||||
component: Union[Component, ComponentCallable]
|
component: Component
|
||||||
route: str
|
route: str
|
||||||
title: str
|
title: str
|
||||||
description: str
|
description: str
|
||||||
@ -239,6 +241,9 @@ class App(MiddlewareMixin, LifespanMixin, Base):
|
|||||||
# A map from a route to an uncompiled page. PRIVATE.
|
# A map from a route to an uncompiled page. PRIVATE.
|
||||||
uncompiled_pages: Dict[str, UncompiledPage] = {}
|
uncompiled_pages: Dict[str, UncompiledPage] = {}
|
||||||
|
|
||||||
|
# A map from a route to an uncompiled page. PRIVATE.
|
||||||
|
uncompiled_pages: Dict[str, UncompiledPage] = {}
|
||||||
|
|
||||||
# A map from a page route to the component to render. Users should use `add_page`. PRIVATE.
|
# A map from a page route to the component to render. Users should use `add_page`. PRIVATE.
|
||||||
pages: Dict[str, Component] = {}
|
pages: Dict[str, Component] = {}
|
||||||
|
|
||||||
@ -534,6 +539,31 @@ class App(MiddlewareMixin, LifespanMixin, Base):
|
|||||||
state = self.state if self.state else State
|
state = self.state if self.state else State
|
||||||
state.setup_dynamic_args(get_route_args(route))
|
state.setup_dynamic_args(get_route_args(route))
|
||||||
|
|
||||||
|
if on_load:
|
||||||
|
self.load_events[route] = (
|
||||||
|
on_load if isinstance(on_load, list) else [on_load]
|
||||||
|
)
|
||||||
|
|
||||||
|
self.uncompiled_pages[route] = UncompiledPage(
|
||||||
|
component=component,
|
||||||
|
route=route,
|
||||||
|
title=title,
|
||||||
|
description=description,
|
||||||
|
image=image,
|
||||||
|
on_load=on_load,
|
||||||
|
meta=meta,
|
||||||
|
)
|
||||||
|
|
||||||
|
def _compile_page(self, route: str):
|
||||||
|
"""Compile a page.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
route: The route of the page to compile.
|
||||||
|
"""
|
||||||
|
uncompiled_page = self.uncompiled_pages[route]
|
||||||
|
|
||||||
|
on_load = uncompiled_page.on_load
|
||||||
|
|
||||||
if on_load:
|
if on_load:
|
||||||
self.load_events[route] = (
|
self.load_events[route] = (
|
||||||
on_load if isinstance(on_load, list) else [on_load]
|
on_load if isinstance(on_load, list) else [on_load]
|
||||||
|
Loading…
Reference in New Issue
Block a user