StateManager
Import :
const StateManager = brackets.getModule("preferences/StateManager")
_
StateManager
Kind: global constant
PROJECT_CONTEXT : string
Project specific context
Kind: global constant
GLOBAL_CONTEXT : string
Global context
Kind: global constant
PROJECT_THEN_GLOBAL_CONTEXT : string
Project or global context
Kind: global constant
getVal(id, [context])
Convenience function that gets a view state
Kind: global function
Param | Type | Description |
---|---|---|
id | string | preference to get |
[context] | Object | string | Optional additional information about the request, can be: - ScopeManager.PROJECT_CONTEXT if you want to get project specific value or - ScopeManager.GLOBAL_CONTEXT if you want to get it from global context and not the project context. - null/undefined if you want to get from project context first, and then global context if not found in project context. |
[context.scope] | string | Eg. user - deprecated, do not use |
[context.layer] | string | Eg. project - deprecated, do not use |
[context.layerID] | string | Eg. /tauri/path/to/project - deprecated, do not use |
setVal(id, value, [context])
Convenience function that sets a view state and then saves the file
Kind: global function
Param | Type | Description |
---|---|---|
id | string | preference to set |
value | * | new value for the preference |
[context] | Object | string | Optional additional information about the request, can be: ScopeManager.PROJECT_CONTEXT if you want to get project specific value or ScopeManager.GLOBAL_CONTEXT or null if you want to set globally. |
[context.scope] | string | Eg. user - deprecated, do not use |
[context.layer] | string | Eg. project - deprecated, do not use |
[context.layerID] | string | Eg. /tauri/path/to/project - deprecated, do not use |
definePreferenceInternal(id, type, initial, options) ⇒ Object
returns a preference instance that can be listened .on("change", cbfn(changeType))
. The callback fucntion will be called
whenever there is a change in the supplied id with a changeType argument. The change type can be one of the two:
CHANGE_TYPE_INTERNAL - if change is made within the current app window/browser tap
CHANGE_TYPE_EXTERNAL - if change is made in a different app window/browser tab
Kind: global function
Param |
---|
id |
type |
initial |
options |
getPreferenceInternal(id) ⇒ Object
Get the preference instance for the given ID.
Kind: global function
Param | Type |
---|---|
id | string |
createExtensionStateManager(extensionID) ⇒ object
create a state manager for an extension. ensure that the IDs are unique.
Kind: global function
Returns: object
- Object with methods to manage the extension's state and preferences.
get(id, context)
: Get the value from the extension's state.set(id, value, context)
: Set the value in the extension's state.definePreference(id, type, initial, options)
: define a preference for the extension.getPreference(id)
: retrieve a defined preference.PROJECT_CONTEXT
,GLOBAL_CONTEXT
,PROJECT_THEN_GLOBAL_CONTEXT
: constant for context management.
Param | Type |
---|---|
extensionID | string |