Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const workerProgressAssign = assign((ctx, e) => {
const { progress } = e.job
// console.log( `workerMachine ${id}: ${progress}` )
ctx.progress = progress
return ctx
})
export const workerDoneAssign = assign((ctx, e) => {
// console.log( '\t[workerDone]', ctx, e )
const { progress } = e.job
ctx.progress = progress
return ctx
})
export const workerDoneSend = sendParent((ctx, e) => ({
type: MainTypes.updateJob,
song: ctx,
}))
export const pauseFileAssign = assign((ctx, e) => {
// console.log('\t[pauseFile]', e.id)
})
export const pauseFileSend = send(
(ctx, e) => ({
type: CompServiceTypes.pauseSong,
data: ctx.id,
}),
{ to: 'CompressionService' },
)
on: {
[SET_SEARCH_VALUE]: [
{
target: 'search.fetching',
cond: 'shouldFetchMovies',
actions: 'setSearchValueInState',
},
{
target: 'search.idle',
actions: 'setSearchValueInState',
},
],
[FETCH_MOVIE]: {
target: 'movie.fetching',
cond: 'shouldFetchMovie',
actions: sendParent((context, event) => ({
type: ADD_MOVIE_TO_ACTIVE_LIST,
movieId: event.id,
})),
},
},
},
{
actions: {
setSearchValueInState: assign(
produce((draftContext, action) => {
draftContext.currentSearchValue = action.value;
}),
),
movieSearchResultReceived: assign(
produce((draftContext, event) => {
draftContext.searchKeys[draftContext.currentSearchValue] = event.data;
(ctx, e) => ({
type: CompServiceTypes.resumeSong,
data: { id: ctx.id, progress: ctx.progress },
}),
{ to: 'CompressionService' },
)
export const cancelFileSend = send(
(ctx, e) => ({
type: CompServiceTypes.cancelSong,
data: ctx.id,
}),
{ to: 'CompressionService' },
)
export const cancelFileSendParent = sendParent((ctx, e) => ({
type: MainTypes.cancelJob,
id: ctx.id,
}))