Skip to content

How to use Quasar's q-pull-to-refresh component in NiceGUI #3628

Closed Answered by falkoschindler
flintcreek asked this question in Q&A
Discussion options

You must be logged in to vote

Here is a more advanced version that actually waits for the refresh to complete:

with ui.element('q-pull-to-refresh') as pull_to_refresh:
    label = ui.label('content to refresh')

pull_to_refresh.on('refresh', js_handler='''
    (done) => {
        emitEvent("refresh");
        window.refresh_complete = false;
        const interval = setInterval(() => {
            if (window.refresh_complete) {
                done();
                clearInterval(interval);
            }
        }, 100);
    }
''')

async def refresh():
    await asyncio.sleep(0.5)
    label.text = 'refreshed'
    ui.run_javascript('window.refresh_complete = true')

ui.on('refresh', refresh)

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@falkoschindler
Comment options

Answer selected by flintcreek
@flintcreek
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants