Allow creating a new page per client #61
Replies: 7 comments 2 replies
-
Maybe the assumptions in #70 will break when this is implemented. |
Beta Was this translation helpful? Give feedback.
-
I looked into @me21's proposal in #6 and it seems very reasonable. Keeping all individual pages in a dictionary is an idea I haven't thought about. But of course, you need to keep track of which pages to throw away after its last socket is closed. What I'm wondering about: What is actually the desired behavior, shared or separate state between tabs of the same browser? So pages are either referred to by session ID or socket instance. |
Beta Was this translation helpful? Give feedback.
-
I experimented with an implementation of a "private page" and came up with two approaches and another variant.
|
Beta Was this translation helpful? Give feedback.
-
@falkoschindler I think approach 3 is also quite confusing. Most people do not now about parameters passed to classes. Also the page builder would have no obvious connection to the What do you think about this API: @ui.get('/plain')
def plain():
return responses.PlainTextResponse(f'some plain text')
@ui.page('/private_page')
def private_page():
ui.label(f'your private page {uuid4()}')
ui.link('show plain response', '/plain')
ui.link('open new page', '/private_page') |
Beta Was this translation helpful? Give feedback.
-
Let me summarize the current proposals - my three + the one from @rodja + another one he came up with just now:
|
Beta Was this translation helpful? Give feedback.
-
I have fallen in love with the 5th proposal. With the latest push to #61-page-decorator I introduced a breaking change: all pages must be created via a decorator (including the index page): @ui.page('/private_page', shared=False)
def private_page():
ui.label(f'your private page with uuid {uuid4()}')
@ui.page('/shared_page', shared=True)
def shared_page():
ui.label(f'a shared page with uuid {uuid4()}')
@ui.page('/', shared=True)
def index():
ui.link('shared page', '/shared_page')
ui.link('private page', '/private_page') I think using a context for pages was confusing from the start (see #50 for example). |
Beta Was this translation helpful? Give feedback.
-
@rodja I've created a new issue #85 for tracking the actual development of this feature. Let's continue the discussion there. |
Beta Was this translation helpful? Give feedback.
-
Idea:
ui.page
can not only be used as context, but also accepts aCallable
argument for re-creating the page whenever a client connects.If the path if
/
or omitted, the page replaces the main page.This is related to #6, where @me21 posted a draft for a
PrivatePage
, which I haven't looked into, yet.Beta Was this translation helpful? Give feedback.
All reactions