refactor(store): remove partial slice state updates (#296)

This commit is contained in:
rahim
2026-01-06 14:23:00 +11:00
committed by GitHub
parent 0354e3ef9c
commit bb2b54e86f
12 changed files with 56 additions and 89 deletions
+2 -3
View File
@@ -22,9 +22,8 @@ export const bufferSlice = createSlice<HTMLMediaElement>()({
}),
subscribe: ({ target, update, signal }) => {
const sync = () => update();
listen(target, 'progress', sync, { signal });
listen(target, 'emptied', sync, { signal });
listen(target, 'progress', update, { signal });
listen(target, 'emptied', update, { signal });
},
request: {},
@@ -28,12 +28,11 @@ export const playbackSlice = createSlice<HTMLMediaElement>()({
}),
subscribe: ({ target, update, signal }) => {
const sync = () => update();
listen(target, 'play', sync, { signal });
listen(target, 'pause', sync, { signal });
listen(target, 'ended', sync, { signal });
listen(target, 'playing', sync, { signal });
listen(target, 'waiting', sync, { signal });
listen(target, 'play', update, { signal });
listen(target, 'pause', update, { signal });
listen(target, 'ended', update, { signal });
listen(target, 'playing', update, { signal });
listen(target, 'waiting', update, { signal });
},
request: {
+4 -5
View File
@@ -22,11 +22,10 @@ export const sourceSlice = createSlice<HTMLMediaElement>()({
}),
subscribe: ({ target, update, signal }) => {
const sync = () => update();
listen(target, 'canplay', sync, { signal });
listen(target, 'canplaythrough', sync, { signal });
listen(target, 'loadstart', sync, { signal });
listen(target, 'emptied', sync, { signal });
listen(target, 'canplay', update, { signal });
listen(target, 'canplaythrough', update, { signal });
listen(target, 'loadstart', update, { signal });
listen(target, 'emptied', update, { signal });
},
request: {
+5 -6
View File
@@ -22,12 +22,11 @@ export const timeSlice = createSlice<HTMLMediaElement>()({
}),
subscribe: ({ target, update, signal }) => {
const sync = () => update();
listen(target, 'timeupdate', sync, { signal });
listen(target, 'durationchange', sync, { signal });
listen(target, 'seeked', sync, { signal });
listen(target, 'loadedmetadata', sync, { signal });
listen(target, 'emptied', sync, { signal });
listen(target, 'timeupdate', update, { signal });
listen(target, 'durationchange', update, { signal });
listen(target, 'seeked', update, { signal });
listen(target, 'loadedmetadata', update, { signal });
listen(target, 'emptied', update, { signal });
},
request: {
+1 -2
View File
@@ -22,8 +22,7 @@ export const volumeSlice = createSlice<HTMLMediaElement>()({
}),
subscribe: ({ target, update, signal }) => {
const sync = () => update();
listen(target, 'volumechange', sync, { signal });
listen(target, 'volumechange', update, { signal });
},
request: {