Now using redux to not create sound player every time the phaser is also implicitely cached
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
||||
import { SplendidGrandPiano } from 'smplr';
|
||||
|
||||
export const soundPlayerSlice = createSlice({
|
||||
name: 'soundPlayer',
|
||||
initialState: {
|
||||
soundPlayer: undefined as SplendidGrandPiano | undefined,
|
||||
},
|
||||
reducers: {
|
||||
setSoundPlayer: (state, action: PayloadAction<SplendidGrandPiano>) => {
|
||||
state.soundPlayer = action.payload;
|
||||
},
|
||||
unsetSoundPlayer: (state) => {
|
||||
state.soundPlayer = undefined;
|
||||
},
|
||||
},
|
||||
});
|
||||
export const { setSoundPlayer, unsetSoundPlayer } = soundPlayerSlice.actions;
|
||||
export default soundPlayerSlice.reducer;
|
||||
Reference in New Issue
Block a user