import { select , takeLatest } from "typed-redux-saga" ; import { BoardSlice , BoardState } from "@shoki/board" ; import { PieceModel } from "@creature-chess/models" ; import { PlayerState } from "@creature-chess/gamemode" ; param slice The  BoardSlice to use
 *  param selector A selector function for the  BoardState from  PlayerState param callback The callback function with the  BoardState export const subscribeToBoard = function * ( slice , selector , callback ) { const initialState = yield * select ( selector ) ; callback ( initialState ) ; yield takeLatest ( [ slice . commands . addBoardPieceCommand , slice . commands . moveBoardPieceCommand , slice . commands . removeBoardPiecesCommand , slice . commands . updateBoardPiecesCommand , slice . commands . swapPiecesCommand ] , function * ( ) { const state = yield * select ( selector ) ; callback ( state ) ; } ) ; } ;