UNPKG

4.01 kBTypeScriptView Raw
1import { ConfigValues, Disposable, ScopeDescriptor } from "../index";
2
3/** Used to access all of Atom's configuration details. */
4export interface Config {
5 // Config Subscription
6 /**
7 * Add a listener for changes to a given key path. This is different than ::onDidChange in
8 * that it will immediately call your callback with the current value of the config entry.
9 */
10 observe<T extends keyof ConfigValues>(keyPath: T, callback: (value: ConfigValues[T]) => void): Disposable;
11 /**
12 * Add a listener for changes to a given key path. This is different than ::onDidChange in
13 * that it will immediately call your callback with the current value of the config entry.
14 */
15 observe<T extends keyof ConfigValues>(
16 keyPath: T,
17 options: { scope: string[] | ScopeDescriptor },
18 callback: (value: ConfigValues[T]) => void,
19 ): Disposable;
20
21 /**
22 * Add a listener for changes to a given key path. If keyPath is not specified, your
23 * callback will be called on changes to any key.
24 */
25 // tslint:disable-next-line:no-any
26 onDidChange<T = any>(callback: (values: { newValue: T; oldValue: T }) => void): Disposable;
27 /**
28 * Add a listener for changes to a given key path. If keyPath is not specified, your
29 * callback will be called on changes to any key.
30 */
31 onDidChange<T extends keyof ConfigValues>(
32 keyPath: T,
33 callback: (values: { newValue: ConfigValues[T]; oldValue?: ConfigValues[T] | undefined }) => void,
34 ): Disposable;
35 /**
36 * Add a listener for changes to a given key path. If keyPath is not specified, your
37 * callback will be called on changes to any key.
38 */
39 onDidChange<T extends keyof ConfigValues>(
40 keyPath: T,
41 options: { scope: string[] | ScopeDescriptor },
42 callback: (values: { newValue: ConfigValues[T]; oldValue?: ConfigValues[T] | undefined }) => void,
43 ): Disposable;
44
45 // Managing Settings
46 /** Retrieves the setting for the given key. */
47 get<T extends keyof ConfigValues>(
48 keyPath: T,
49 options?: {
50 sources?: string[] | undefined;
51 excludeSources?: string[] | undefined;
52 scope?: string[] | ScopeDescriptor | undefined;
53 },
54 ): ConfigValues[T];
55
56 /**
57 * Sets the value for a configuration setting.
58 * This value is stored in Atom's internal configuration file.
59 */
60 set<T extends keyof ConfigValues>(
61 keyPath: T,
62 value: ConfigValues[T],
63 options?: { scopeSelector?: string | undefined; source?: string | undefined },
64 ): void;
65
66 /** Restore the setting at keyPath to its default value. */
67 unset(keyPath: string, options?: { scopeSelector?: string | undefined; source?: string | undefined }): void;
68
69 /**
70 * Get all of the values for the given key-path, along with their associated
71 * scope selector.
72 */
73 getAll<T extends keyof ConfigValues>(
74 keyPath: T,
75 options?: {
76 sources?: string[] | undefined;
77 excludeSources?: string[] | undefined;
78 scope?: ScopeDescriptor | undefined;
79 },
80 ): Array<{ scopeDescriptor: ScopeDescriptor; value: ConfigValues[T] }>;
81
82 /**
83 * Get an Array of all of the source Strings with which settings have been added
84 * via ::set.
85 */
86 getSources(): string[];
87
88 /**
89 * Retrieve the schema for a specific key path. The schema will tell you what type
90 * the keyPath expects, and other metadata about the config option.
91 */
92 getSchema(keyPath: string): object | null;
93
94 /** Get the string path to the config file being used. */
95 getUserConfigPath(): string;
96
97 /**
98 * Suppress calls to handler functions registered with ::onDidChange and ::observe
99 * for the duration of callback. After callback executes, handlers will be called
100 * once if the value for their key-path has changed.
101 */
102 transact(callback: () => void): void;
103}
104
\No newline at end of file