e08_refresh_cache_v1#

Feature:

No matter what user entered, always return a random value between 1 and 100. And this value is based on cache that won’t change while user is typing. However, we want to provide a way to refresh the value. User can type “!~” and then hit ENTER to refresh the value. When user hit ENTER, it automatically removes the “!~” part and recover the original query.

Difficulty: Hard

Dependencies: NA

Demo: https://asciinema.org/a/631197

class zelfred.gallery.e08_refresh_cache_v1.RefreshItem(title: str, subtitle: ~typing.Optional[str] = None, uid: str = <factory>, arg: ~typing.Optional[str] = None, autocomplete: ~typing.Optional[str] = None, variables: ~typing.Dict[str, ~typing.Any] = <factory>)[source]#

Represent an item that can refresh cache in the dropdown menu.

enter_handler(ui: UI)[source]#

Copy the content to clipboard.

post_enter_handler(ui: UI)[source]#

After the user input action, we would like to repaint the dropdown menu only to show the “Copied” item, and then wait for the next user input.

zelfred.gallery.e08_refresh_cache_v1.handler(query: str, ui: UI)[source]#

The handler is the core of a Zelfred App. It’s a user-defined function that takes the entered query and the UI object as inputs and returns a list of items to render.