ywana-core8 0.0.696 → 0.0.698
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 +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.modern.js +6 -3
- package/dist/index.modern.js.map +1 -1
- package/dist/index.umd.js +6 -3
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/incubator/task.js +5 -2
package/package.json
CHANGED
package/src/incubator/task.js
CHANGED
@@ -48,7 +48,7 @@ export const TaskContextProvider = (props) => {
|
|
48
48
|
|
49
49
|
async function removeTask(id) {
|
50
50
|
try {
|
51
|
-
|
51
|
+
removeListener(id)
|
52
52
|
const response = await API.remove(id);
|
53
53
|
return response;
|
54
54
|
} catch (error) {
|
@@ -62,14 +62,16 @@ export const TaskContextProvider = (props) => {
|
|
62
62
|
return listenerId
|
63
63
|
}
|
64
64
|
|
65
|
-
function
|
65
|
+
function removeListener(taskId) {
|
66
66
|
const newListeners = listeners.filter(listener => listener.taskId !== taskId)
|
67
|
+
console.log("removeListener", taskId, newListeners)
|
67
68
|
setListeners(newListeners)
|
68
69
|
}
|
69
70
|
|
70
71
|
useEffect(() => {
|
71
72
|
const interval = setInterval(async () => {
|
72
73
|
const tasks = await API.all()
|
74
|
+
console.log(listeners)
|
73
75
|
listeners.forEach(({ taskId, listener }) => {
|
74
76
|
const task = tasks.find(task => task.id === taskId)
|
75
77
|
if (task) listener(task)
|
@@ -85,6 +87,7 @@ export const TaskContextProvider = (props) => {
|
|
85
87
|
createTask,
|
86
88
|
removeTask,
|
87
89
|
addListener,
|
90
|
+
removeListener
|
88
91
|
};
|
89
92
|
|
90
93
|
return (
|