We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have a test. The test passes.
import { makeAutoObservable, toJS } from 'mobx'; import { serialize, update } from 'serializr'; import { persist } from 'mobx-persist'; class StoreOneItem { constructor(public name: string, public id: string) { makeAutoObservable(this); } } class StoreOne { constructor( public lines: string[], // mobx-persist can't serialize this public items: StoreOneItem[], ) { makeAutoObservable(this); } get linesCount(): number { return this.lines.length; } public setLines(lines: string[]) { this.lines = lines; } } const schema = { lines: false, items: { type: 'list', schema: { name: true, id: true, }, }, }; persist(schema)(StoreOne); it('save', () => { const targetStorage = new StoreOne( ['first', 'second'], [new StoreOneItem('item-1', 'item-1-id')], ); expect(serialize(targetStorage)).toEqual({ items: [ { id: 'item-1-id', name: 'item-1', }, ], }); });
Case 1. But, if I change schema to:
const schema = { lines: true, items: { type: 'list', schema: { name: true, id: true, }, }, };
I'll get an error:
Error: [serializr] this value is not primitive: first,second
Case 2. Or if I change schema to:
const schema = { lines: { type: 'list', schema: true, }, items: { type: 'list', schema: { name: true, id: true, }, }, };
I'll get another error:
[serializr] No modelschema provided. If you are importing it from another file be aware of circular dependencies.
Can I serialize array of primitives?
Package versions:
"mobx": "6.0.1", "mobx-persist": "^0.4.1", "version": "1.5.4"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I have a test. The test passes.
Case 1. But, if I change schema to:
I'll get an error:
Case 2. Or if I change schema to:
I'll get another error:
Can I serialize array of primitives?
Package versions:
The text was updated successfully, but these errors were encountered: