Skip to main content

Suspense like tag for reactpy library or lilliepy framework

Project description

lilliepy-rebound

suspense tag but for react py

Usage:

two ways to use rebounds:

  • Rebound(fallback: ComponentType, requestfn: Callable[..., Awaitable]) -> Callable[[ComponentType], ComponentType]
  • inRebound(_component : ComponentType | VdomDict, fallback: ComponentType | VdomDict, requestfn: Callable[..., Awaitable]) -> VdomDict | ComponentType

@Rebound()

This is the way to use the decorator version of Rebounding

from reactpy import component, html, run
from lilliepy_rebound import Rebound
from requests import get

async def get_data():
   #expensive request
   return get("http://127.0.0.1:5000/hello").json()

@component
@Rebound(fallback=html.h1("Loading..."), requestfn=get_data)
def MyComponent(data):
    return html._(
            html.h1(f"{data}")
        )

run(MyComponent)

the Rebound functions gives a param res to the component it is attached to. res contains the data received when the request is complete

inRebound()

This is the way to use the component version of Rebounding

from reactpy import component, html, run
from lilliepy_rebound import Rebound, inRebound
from requests import get

async def get_data():
   #expensive request
   return get("http://127.0.0.1:5000/hello").json()

@component
def MyComponent():
    return html._(
            inRebound(lambda data: html.div(f"Result: {data['data']}"), html.div("Loading..."), get_data)
        )

run(MyComponent)

basically the same thing as Rebound but it is a component instead of a decorator

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lilliepy_rebound-0.0.1.tar.gz (2.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lilliepy_rebound-0.0.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file lilliepy_rebound-0.0.1.tar.gz.

File metadata

  • Download URL: lilliepy_rebound-0.0.1.tar.gz
  • Upload date:
  • Size: 2.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for lilliepy_rebound-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f5a66e072bc7bce337256418fc70a8517f97b46b5d7158c9492167c2ab3b9ac1
MD5 1c36ad416ad43420a5fab8994473f155
BLAKE2b-256 7eb4ced48114e9ca20b29aec27ae3b498a76773c4de33b6f5b48de785f50dc1b

See more details on using hashes here.

File details

Details for the file lilliepy_rebound-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for lilliepy_rebound-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fca1edf9a16a8ef11781001f98fce718cbba37ff4c43ae49e06df28fb1ae670c
MD5 edccfca403f9c699a1dd70711e21bef3
BLAKE2b-256 b573bf7d99533bcc47e5b5c12b32dad03c00f7e90d751f220a9f21afca071a30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page