mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-04-22 19:27:57 +00:00
21 lines
564 B
TypeScript
21 lines
564 B
TypeScript
// Copyright 2017-2026 @pezkuwi/react-api authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { OnChangeCb } from '../types.js';
|
|
|
|
import { isFunction, isObservable } from '@pezkuwi/util';
|
|
|
|
export function triggerChange (value?: unknown, ...callOnResult: (OnChangeCb | undefined)[]): void {
|
|
if (!callOnResult?.length) {
|
|
return;
|
|
}
|
|
|
|
callOnResult.forEach((callOnResult): void => {
|
|
if (isObservable(callOnResult)) {
|
|
callOnResult.next(value);
|
|
} else if (isFunction(callOnResult)) {
|
|
callOnResult(value);
|
|
}
|
|
});
|
|
}
|