@@ -145,6 +145,13 @@ export function useTriliumOption(name: OptionNames, needsRefresh?: boolean): [st
145145 ]
146146}
147147
148+ /**
149+ * Similar to {@link useTriliumOption}, but the value is converted to and from a boolean instead of a string.
150+ *
151+ * @param name the name of the option to listen for.
152+ * @param needsRefresh whether to reload the frontend whenever the value is changed.
153+ * @returns an array where the first value is the current option value and the second value is the setter.
154+ */
148155export function useTriliumOptionBool ( name : OptionNames , needsRefresh ?: boolean ) : [ boolean , ( newValue : boolean ) => Promise < void > ] {
149156 const [ value , setValue ] = useTriliumOption ( name , needsRefresh ) ;
150157 return [
@@ -153,6 +160,13 @@ export function useTriliumOptionBool(name: OptionNames, needsRefresh?: boolean):
153160 ]
154161}
155162
163+ /**
164+ * Similar to {@link useTriliumOption}, but the value is converted to and from a int instead of a string.
165+ *
166+ * @param name the name of the option to listen for.
167+ * @param needsRefresh whether to reload the frontend whenever the value is changed.
168+ * @returns an array where the first value is the current option value and the second value is the setter.
169+ */
156170export function useTriliumOptionInt ( name : OptionNames ) : [ number , ( newValue : number ) => Promise < void > ] {
157171 const [ value , setValue ] = useTriliumOption ( name ) ;
158172 return [
@@ -161,6 +175,12 @@ export function useTriliumOptionInt(name: OptionNames): [number, (newValue: numb
161175 ]
162176}
163177
178+ /**
179+ * Similar to {@link useTriliumOption}, but the object value is parsed to and from a JSON instead of a string.
180+ *
181+ * @param name the name of the option to listen for.
182+ * @returns an array where the first value is the current option value and the second value is the setter.
183+ */
164184export function useTriliumOptionJson < T > ( name : OptionNames ) : [ T , ( newValue : T ) => Promise < void > ] {
165185 const [ value , setValue ] = useTriliumOption ( name ) ;
166186 return [
@@ -169,6 +189,12 @@ export function useTriliumOptionJson<T>(name: OptionNames): [ T, (newValue: T) =
169189 ] ;
170190}
171191
192+ /**
193+ * Similar to {@link useTriliumOption}, but operates with multiple options at once.
194+ *
195+ * @param names the name of the option to listen for.
196+ * @returns an array where the first value is a map where the keys are the option names and the values, and the second value is the setter which takes in the same type of map and saves them all at once.
197+ */
172198export function useTriliumOptions < T extends OptionNames > ( ...names : T [ ] ) {
173199 const values : Record < string , string > = { } ;
174200 for ( const name of names ) {
0 commit comments