Wp.State¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The file name where the state will be stored |
||
r/w |
The timeout in milliseconds to save the state |
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Wp.State(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
The
Wp.State
class saves and loads properties from a file- classmethod new(name)¶
-
Constructs a new state object.
- clear()¶
Clears the state removing its file.
- get_location()¶
- Returns:
the location of this state
- Return type:
Gets the location of a state object.
- load()¶
- Returns:
a new
Wp.Properties
containing the state data- Return type:
Loads the state data from the file system.
This function will never fail. If it cannot load the state, for any reason, it will simply return an empty
Wp.Properties
, behaving as if there was no previous state stored.
- save(props)¶
- Parameters:
props (
Wp.Properties
) – the properties to save- Raises:
- Returns:
- Return type:
Saves new properties in the state, overwriting all previous data.
- save_after_timeout(core, props)¶
- Parameters:
core (
Wp.Core
) – the core, used to add the timeout callback to the main loopprops (
Wp.Properties
) – the properties to save. This object will be referenced and kept alive until the timeout elapses, but not deep copied.
Saves new properties in the state, overwriting all previous data, after a timeout.
This is similar to
Wp.State.save
() but it will save the state after a timeout has elapsed. If the state is saved again before the timeout elapses, the timeout is reset. This function is useful to avoid saving the state too often. When called consecutively, it will save the state only once. Every time it is called, it will cancel the previous timer and start a new one, resulting in timing out only after the last call.New in version 0.5.0.
Property Details¶
- Wp.State.props.name¶
- Name:
name
- Type:
- Default Value:
- Flags:
The file name where the state will be stored