use-lines-change@0.1.0
optionsに{initialize: true}を渡すと、eventの発生に関わらず最初に一回だけcallbackを実行してくれる
code:script.js
import {useEffect} from '../preact@10.5.13/hooks.js';
export function useLinesChange(callback, options = {}, deps = []) {
useEffect(() => {
if (options?.initialize) callback();
scrapbox.addListener('lines:changed', callback);
return () => scrapbox.removeListener('lines:changed', callback);
}