| 23 | |
| 24 | |
| 25 | def wrap_builder(old_builder): |
| 26 | # This is the bit that we're injecting to get the example components to reload too |
| 27 | |
| 28 | app = make_app("docs_dev_app") |
| 29 | |
| 30 | thread_started = threading.Event() |
| 31 | |
| 32 | def run_in_thread(): |
| 33 | loop = asyncio.new_event_loop() |
| 34 | asyncio.set_event_loop(loop) |
| 35 | |
| 36 | server_started = asyncio.Event() |
| 37 | |
| 38 | async def set_thread_event_when_started(): |
| 39 | await server_started.wait() |
| 40 | thread_started.set() |
| 41 | |
| 42 | loop.run_until_complete( |
| 43 | asyncio.gather( |
| 44 | serve_development_app(app, "127.0.0.1", 5555, server_started), |
| 45 | set_thread_event_when_started(), |
| 46 | ) |
| 47 | ) |
| 48 | |
| 49 | threading.Thread(target=run_in_thread, daemon=True).start() |
| 50 | |
| 51 | thread_started.wait() |
| 52 | |
| 53 | def new_builder(): |
| 54 | clear_reactpy_web_modules_dir() |
| 55 | reload_examples() |
| 56 | old_builder() |
| 57 | |
| 58 | return new_builder |
| 59 | |
| 60 | |
| 61 | def main(): |