()
| 310 | let didUnsubscribe = false; |
| 311 | |
| 312 | const checkForUpdates = () => { |
| 313 | if (didUnsubscribe) { |
| 314 | return; |
| 315 | } |
| 316 | |
| 317 | setState(prevState => { |
| 318 | if ( |
| 319 | prevState.getCurrentValue !== getCurrentValue || |
| 320 | prevState.subscribe !== subscribe |
| 321 | ) { |
| 322 | return prevState; |
| 323 | } |
| 324 | |
| 325 | const value = getCurrentValue(); |
| 326 | if (prevState.value === value) { |
| 327 | return prevState; |
| 328 | } |
| 329 | |
| 330 | return {...prevState, value}; |
| 331 | }); |
| 332 | }; |
| 333 | const unsubscribe = subscribe(checkForUpdates); |
| 334 | |
| 335 | checkForUpdates(); |
no test coverage detected