Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { serializable, list, createSimpleSchema, primitive, object, custom, SKIP } from 'serializr';
import { observable, toJS } from 'mobx';
var Action = createSimpleSchema({
type: primitive(),
payload: custom(
(value) => value === undefined ? SKIP : toJS(value),
(value) => value
),
});
var Milestone = createSimpleSchema({
chapterId: primitive(),
index: primitive(),
});
class TutorialState {
@serializable @observable currentChapterId;
@serializable(list(object(Action))) @observable actions = [];
@serializable(list(object(Milestone))) @observable milestones = [];
static create({ chapters }) {
const state = new TutorialState();
state.currentChapterId = chapters[0].id;
return state;
}
Object.keys(params).forEach(function (key) {
if (typeof params[key] === 'object') {
if (params[key].type in types_1.types) {
if (typeof params[key].schema === 'object') {
schema[key] = types_1.types[params[key].type](createModel(params[key].schema));
}
else {
schema[key] = types_1.types[params[key].type](params[key].schema);
}
}
}
else if (params[key] === true) {
schema[key] = true;
}
});
return serializr_1.createSimpleSchema(schema);
}
import { serializable, list, createSimpleSchema, primitive, object, custom, SKIP } from 'serializr';
import { observable, toJS } from 'mobx';
var Action = createSimpleSchema({
type: primitive(),
payload: custom(
(value) => value === undefined ? SKIP : toJS(value),
(value) => value
),
});
var Milestone = createSimpleSchema({
chapterId: primitive(),
index: primitive(),
});
class TutorialState {
@serializable @observable currentChapterId;
@serializable(list(object(Action))) @observable actions = [];
@serializable(list(object(Milestone))) @observable milestones = [];