@reactuses/core 6.0.2 → 6.0.3-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -3469,19 +3469,24 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3469
3469
  }
3470
3470
  });
3471
3471
  });
3472
- const close = React.useCallback(()=>{
3472
+ const close = React.useCallback((explicit = false)=>{
3473
3473
  var _eventSourceRef_current;
3474
3474
  setStatus('DISCONNECTED');
3475
3475
  clean();
3476
3476
  (_eventSourceRef_current = eventSourceRef.current) == null ? void 0 : _eventSourceRef_current.close();
3477
3477
  eventSourceRef.current = null;
3478
- explicitlyClosed.current = true;
3478
+ explicitlyClosed.current = explicit;
3479
3479
  }, [
3480
3480
  clean
3481
3481
  ]);
3482
+ const explicitlyClose = React.useCallback(()=>{
3483
+ close(true);
3484
+ }, [
3485
+ close
3486
+ ]);
3482
3487
  const open = useEvent(()=>{
3483
3488
  close();
3484
- explicitlyClosed.current = false;
3489
+ setStatus('CONNECTING');
3485
3490
  retries.current = 0;
3486
3491
  if (!eventSourceRef.current) {
3487
3492
  eventSourceRef.current = new EventSource(url, {
@@ -3542,7 +3547,7 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3542
3547
  status,
3543
3548
  lastEventId,
3544
3549
  event,
3545
- close,
3550
+ close: explicitlyClose,
3546
3551
  open
3547
3552
  };
3548
3553
  };
package/dist/index.mjs CHANGED
@@ -3461,19 +3461,24 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3461
3461
  }
3462
3462
  });
3463
3463
  });
3464
- const close = useCallback(()=>{
3464
+ const close = useCallback((explicit = false)=>{
3465
3465
  var _eventSourceRef_current;
3466
3466
  setStatus('DISCONNECTED');
3467
3467
  clean();
3468
3468
  (_eventSourceRef_current = eventSourceRef.current) == null ? void 0 : _eventSourceRef_current.close();
3469
3469
  eventSourceRef.current = null;
3470
- explicitlyClosed.current = true;
3470
+ explicitlyClosed.current = explicit;
3471
3471
  }, [
3472
3472
  clean
3473
3473
  ]);
3474
+ const explicitlyClose = useCallback(()=>{
3475
+ close(true);
3476
+ }, [
3477
+ close
3478
+ ]);
3474
3479
  const open = useEvent(()=>{
3475
3480
  close();
3476
- explicitlyClosed.current = false;
3481
+ setStatus('CONNECTING');
3477
3482
  retries.current = 0;
3478
3483
  if (!eventSourceRef.current) {
3479
3484
  eventSourceRef.current = new EventSource(url, {
@@ -3534,7 +3539,7 @@ const useEventSource = (url, events = [], options = defaultOptions$1)=>{
3534
3539
  status,
3535
3540
  lastEventId,
3536
3541
  event,
3537
- close,
3542
+ close: explicitlyClose,
3538
3543
  open
3539
3544
  };
3540
3545
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactuses/core",
3
- "version": "6.0.2",
3
+ "version": "6.0.3-beta.1",
4
4
  "license": "Unlicense",
5
5
  "homepage": "https://www.reactuse.com/",
6
6
  "repository": {