Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@serializable(object(TurnStats))
@observable
buff: TurnStats;
@serializable(map(object(TurnStats)))
@observable
dots = new Map();
@serializable(object(Stats))
@observable mutableStats = new Stats();
@serializable(map(primitive()))
@observable
private skillLevels = new Map();
@serializable(map(primitive()))
@observable
private skillSelections = new Map();
get skills () {
return this.classInfo.skills.map((info) => new Skill(this.skillLevels, this.skillSelections, info));
}
get selectedSkills () {
return this.skills.filter((skill) => skill.isSelected);
}
@computed get scaledClassInfo () {
const scaled = {...this.classInfo}; // Clone to avoid mutating static instance
scaled.stats = new Stats();
scaled.stats.add(this.classInfo.stats);
scaled.stats.scale(this.classInfoStatsScale);
test("decorate a property with two decorators", function() {
let updatedByAutorun
class Obj {
x = null
}
decorate(Obj, {
x: [serializable(primitive()), observable]
})
const obj = deserialize(Obj, {
x: 0
})
const d = autorun(() => {
updatedByAutorun = obj.x
})
expect(isObservableProp(obj, "x")).toBe(true)
expect(updatedByAutorun).toEqual(0)
obj.x++
expect(obj.x).toEqual(1)
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;
}
}
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 = [];
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;
}
}
function readonlyPrimitive() {
var defaultSerial = primitive();
return {
serializer: function serializer() {
return undefined;
},
deserializer: defaultSerial.deserializer
};
}
import { serializable, primitive, custom, SKIP } from "serializr";
import { action, computed } from "mobx";
class Action {
@serializable(primitive()) type;
@serializable(custom(
value => value === undefined ? SKIP : value,
json => json
)) payload;
constructor(type, payload) {
this.type = type;
this.payload = payload;
}
is(type) {
return this.type === type.toString();
}
toString() {
return this.type;
field: function field() {
return primitive();
},
session: function session() {