mirror of
https://github.com/hanzoai/frenchdab.git
synced 2026-10-30 18:36:21 +00:00
46 lines
796 B
JavaScript
46 lines
796 B
JavaScript
import {
|
|
action,
|
|
computed,
|
|
observable,
|
|
} from 'mobx'
|
|
|
|
export default class SomeStore {
|
|
@observable someVal = undefined
|
|
@observable user = undefined
|
|
@observable errors = {
|
|
field1: '',
|
|
field2: '',
|
|
}
|
|
|
|
constructor(data) {
|
|
// Do something with seed data if necessary
|
|
}
|
|
|
|
@action
|
|
setProperty(k, v) {
|
|
this[k] = v
|
|
}
|
|
|
|
@action
|
|
setError(k, v) {
|
|
this.errors[k] = v
|
|
}
|
|
|
|
@action
|
|
lynxInit = () => {
|
|
window.addEventListener("lynxMobileLoaded", async () => {
|
|
// lynx is on the window and ready!
|
|
try {
|
|
this.user = await window.lynxMobile.requestSetAccountName()
|
|
} catch (err) {
|
|
console.log('lynx error', err)
|
|
}
|
|
})
|
|
}
|
|
|
|
@computed
|
|
get someComputedValue() {
|
|
return `${this.someVal} is now changed!`
|
|
}
|
|
}
|