(
initialContent?: Content | (() => Content),
)
| 232 | }; |
| 233 | |
| 234 | const startAutoLoad = async ( |
| 235 | initialContent?: Content | (() => Content), |
| 236 | ): Promise<Persister<Persist>> => { |
| 237 | stopAutoLoad(); |
| 238 | await load(initialContent); |
| 239 | await tryCatch( |
| 240 | async () => |
| 241 | (autoLoadHandle = await addPersisterListener( |
| 242 | async (content, changes) => { |
| 243 | if (changes || content) { |
| 244 | /*! istanbul ignore else */ |
| 245 | if (status != StatusValues.Saving) { |
| 246 | setStatus(StatusValues.Loading); |
| 247 | loads++; |
| 248 | setContentOrChanges(changes ?? content); |
| 249 | setStatus(StatusValues.Idle); |
| 250 | await saveAfterMutated(); |
| 251 | } |
| 252 | } else { |
| 253 | await load(); |
| 254 | } |
| 255 | }, |
| 256 | )), |
| 257 | onIgnoredError, |
| 258 | ); |
| 259 | return persister; |
| 260 | }; |
| 261 | |
| 262 | const stopAutoLoad = async (): Promise<Persister<Persist>> => { |
| 263 | if (autoLoadHandle) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…