Skip to content

Commit 29f9ff9

Browse files
authored
Merge pull request #62 from MeetinaXD/feature/usesse-new
feat(useSSE): basic useSSE() implement
2 parents d4f8cba + 79bd803 commit 29f9ff9

24 files changed

+2496
-25
lines changed

package-lock.json

+29
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"@testing-library/jest-dom": "^5.16.4",
4141
"@testing-library/react": "^14.0.0",
4242
"@testing-library/vue": "^7.0.0",
43+
"@types/eventsource": "^1.1.15",
4344
"@types/jest": "^29.2.4",
4445
"@types/react": "^17.0.0",
4546
"@types/react-dom": "^17.0.0",
@@ -58,6 +59,7 @@
5859
"eslint": "^8.29.0",
5960
"eslint-config-prettier": "^8.5.0",
6061
"eslint-plugin-prettier": "^4.2.1",
62+
"eventsource": "^2.0.2",
6163
"husky": "^8.0.3",
6264
"jest": "^29.2.2",
6365
"jest-environment-jsdom": "^29.2.2",

packages/scene-react/index.js

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
import {
22
$,
33
$$,
4+
_$,
5+
_exp$,
6+
_expBatch$,
47
onMounted$,
58
onUnmounted$,
69
upd$,
710
useFlag$,
811
useMemorizedCallback$,
912
useRequestRefState$,
10-
watch$,
11-
_$,
12-
_exp$,
13-
_expBatch$
13+
watch$
1414
} from '@/framework/react';
1515
import { defineProperty, forEach, objectKeys } from '@/helper';
1616
import { trueValue } from '@/helper/variables';
@@ -20,6 +20,7 @@ import useAutoRequest_unified from '@/hooks/useAutoRequest';
2020
import useCaptcha_unified from '@/hooks/useCaptcha';
2121
import useForm_unified from '@/hooks/useForm';
2222
import useRetriableRequest_unified from '@/hooks/useRetriableRequest';
23+
import useSSE_unified from '@/hooks/useSSE';
2324
import { actionDelegationMiddleware as actionDelegationMiddleware_unified } from '@/middlewares/actionDelegation';
2425

2526
export const usePagination = (handler, config = {}) =>
@@ -93,3 +94,20 @@ forEach(objectKeys(useAutoRequest_unified), key => {
9394
trueValue
9495
);
9596
});
97+
98+
// 导出useSSE
99+
export const useSSE = (handler, config = {}) =>
100+
useSSE_unified(
101+
handler,
102+
config,
103+
$,
104+
$$,
105+
_$,
106+
_exp$,
107+
upd$,
108+
watch$,
109+
onMounted$,
110+
onUnmounted$,
111+
useFlag$,
112+
useMemorizedCallback$
113+
);

0 commit comments

Comments
 (0)