beeware / beeware/toga

Add an API for restore/wake-from-sleep for an app

Open
#2,329 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
5.4k
Forks
827
Avg merge
15h 39m
Merged PRs (30d)
40

Description

### What is the problem or limitation you are having?

A well behaved app should, where possible, save its current state when put into a hibernation state (either because of power loss or other hibernation event, such as being moved out of an active state on a mobile device).

### Describe the solution you'd like

A Toga app should be able to:

1. identify hibernation events from the platform
2. save the current app state
3. on restart, restore the previous app state

This means that widgets, windows, and the app itself should provide mechanisms to save their state.

### Describe alternatives you've considered

At the very least, it should be possible for users to implement their own hibernation/restore strategies. This means we should add the lifecycle events, and the mechanisms for adding user-space handlers for those lifecycle events. An initial implementation could be as simple as adding a public API for apps to declare their own manual restore behavior.

### Additional context

A fully fledged solution to this problem will run deep into an app's implementation. It will involve being able to reconstruct the app widget structure, restore any references to widgets, and restore any data sources.

Data sources are especially problematic, as they're an abstract API rather than a literal collection of values. If a data source is implemented as a proxy over an API, it may not be possible to literally "restore" the values, as there may not be an actual underlying data source. Therefore, a data source-backed widget can't just "save its values"; it will need to be able to restore its data source.

The save/restore functionality might also be useful for the niche "reset" use case described by #2317, so that should be kept in mind as part of API design.

Contributor guide

Open the contributing guide

Research direction

No files, tests, or entry points are identified. Start by reviewing the existing app, widget, window, and data-source APIs alongside the reset use case in #2317; done would require a scoped lifecycle and user-handler design that addresses save and restore behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop-dev, mobile-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.