summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorKirill Rogovoy <[email protected]>2021-07-19 20:06:08 +0300
committerKirill Rogovoy <[email protected]>2021-07-19 20:06:08 +0300
commitf0bf4e7afdcd8b02a62be45ab3e7d047ed865a79 (patch)
tree575c0ff2cbb846252bd2e494c81c396846aab2f6 /app/models
parent67ad38d0a7cd319623e9f41c0c381ed5c5f6f973 (diff)
Apply Prettier
Diffstat (limited to 'app/models')
-rw-r--r--app/models/character-store/character-store.test.ts4
-rw-r--r--app/models/character-store/character-store.ts15
-rw-r--r--app/models/character/character.test.ts6
-rw-r--r--app/models/character/character.ts7
-rw-r--r--app/models/environment.ts4
-rw-r--r--app/models/extensions/with-environment.ts4
-rw-r--r--app/models/extensions/with-root-store.ts4
-rw-r--r--app/models/index.ts10
-rw-r--r--app/models/root-store/root-store-context.ts4
-rw-r--r--app/models/root-store/root-store.ts4
-rw-r--r--app/models/root-store/setup-root-store.ts14
11 files changed, 40 insertions, 36 deletions
diff --git a/app/models/character-store/character-store.test.ts b/app/models/character-store/character-store.test.ts
index 6d82079..fc17694 100644
--- a/app/models/character-store/character-store.test.ts
+++ b/app/models/character-store/character-store.test.ts
@@ -1,6 +1,6 @@
-import { CharacterStoreModel } from "./character-store"
+import { CharacterStoreModel } from './character-store'
-test("can be created", () => {
+test('can be created', () => {
const instance = CharacterStoreModel.create({})
expect(instance).toBeTruthy()
diff --git a/app/models/character-store/character-store.ts b/app/models/character-store/character-store.ts
index bd92615..2496fcd 100644
--- a/app/models/character-store/character-store.ts
+++ b/app/models/character-store/character-store.ts
@@ -1,13 +1,13 @@
-import { Instance, SnapshotOut, types } from "mobx-state-tree"
-import { CharacterModel, CharacterSnapshot } from "../character/character"
-import { CharacterApi } from "../../services/api/character-api"
-import { withEnvironment } from "../extensions/with-environment"
+import { Instance, SnapshotOut, types } from 'mobx-state-tree'
+import { CharacterModel, CharacterSnapshot } from '../character/character'
+import { CharacterApi } from '../../services/api/character-api'
+import { withEnvironment } from '../extensions/with-environment'
/**
* Example store containing Rick and Morty characters
*/
export const CharacterStoreModel = types
- .model("CharacterStore")
+ .model('CharacterStore')
.props({
characters: types.optional(types.array(CharacterModel), []),
})
@@ -22,7 +22,7 @@ export const CharacterStoreModel = types
const characterApi = new CharacterApi(self.environment.api)
const result = await characterApi.getCharacters()
- if (result.kind === "ok") {
+ if (result.kind === 'ok') {
self.saveCharacters(result.characters)
} else {
__DEV__ && console.tron.log(result.kind)
@@ -34,4 +34,5 @@ type CharacterStoreType = Instance<typeof CharacterStoreModel>
export interface CharacterStore extends CharacterStoreType {}
type CharacterStoreSnapshotType = SnapshotOut<typeof CharacterStoreModel>
export interface CharacterStoreSnapshot extends CharacterStoreSnapshotType {}
-export const createCharacterStoreDefaultModel = () => types.optional(CharacterStoreModel, {})
+export const createCharacterStoreDefaultModel = () =>
+ types.optional(CharacterStoreModel, {})
diff --git a/app/models/character/character.test.ts b/app/models/character/character.test.ts
index 2f330b4..d7bfac7 100644
--- a/app/models/character/character.test.ts
+++ b/app/models/character/character.test.ts
@@ -1,9 +1,9 @@
-import { CharacterModel } from "./character"
+import { CharacterModel } from './character'
-test("can be created", () => {
+test('can be created', () => {
const instance = CharacterModel.create({
id: 1,
- name: "Rick Sanchez",
+ name: 'Rick Sanchez',
})
expect(instance).toBeTruthy()
diff --git a/app/models/character/character.ts b/app/models/character/character.ts
index ca3cbc7..a9a2e46 100644
--- a/app/models/character/character.ts
+++ b/app/models/character/character.ts
@@ -1,9 +1,9 @@
-import { Instance, SnapshotOut, types } from "mobx-state-tree"
+import { Instance, SnapshotOut, types } from 'mobx-state-tree'
/**
* Rick and Morty character model.
*/
-export const CharacterModel = types.model("Character").props({
+export const CharacterModel = types.model('Character').props({
id: types.identifierNumber,
name: types.maybe(types.string),
status: types.maybe(types.string),
@@ -14,4 +14,5 @@ type CharacterType = Instance<typeof CharacterModel>
export interface Character extends CharacterType {}
type CharacterSnapshotType = SnapshotOut<typeof CharacterModel>
export interface CharacterSnapshot extends CharacterSnapshotType {}
-export const createCharacterDefaultModel = () => types.optional(CharacterModel, {})
+export const createCharacterDefaultModel = () =>
+ types.optional(CharacterModel, {})
diff --git a/app/models/environment.ts b/app/models/environment.ts
index e8569b1..a29586b 100644
--- a/app/models/environment.ts
+++ b/app/models/environment.ts
@@ -1,8 +1,8 @@
-import { Api } from "../services/api"
+import { Api } from '../services/api'
let ReactotronDev
if (__DEV__) {
- const { Reactotron } = require("../services/reactotron")
+ const { Reactotron } = require('../services/reactotron')
ReactotronDev = Reactotron
}
diff --git a/app/models/extensions/with-environment.ts b/app/models/extensions/with-environment.ts
index 9fe5fd5..1fc190e 100644
--- a/app/models/extensions/with-environment.ts
+++ b/app/models/extensions/with-environment.ts
@@ -1,5 +1,5 @@
-import { getEnv, IStateTreeNode } from "mobx-state-tree"
-import { Environment } from "../environment"
+import { getEnv, IStateTreeNode } from 'mobx-state-tree'
+import { Environment } from '../environment'
/**
* Adds a environment property to the node for accessing our
diff --git a/app/models/extensions/with-root-store.ts b/app/models/extensions/with-root-store.ts
index eff769c..72ab478 100644
--- a/app/models/extensions/with-root-store.ts
+++ b/app/models/extensions/with-root-store.ts
@@ -1,5 +1,5 @@
-import { getRoot, IStateTreeNode } from "mobx-state-tree"
-import { RootStoreModel } from "../root-store/root-store"
+import { getRoot, IStateTreeNode } from 'mobx-state-tree'
+import { RootStoreModel } from '../root-store/root-store'
/**
* Adds a rootStore property to the node for a convenient
diff --git a/app/models/index.ts b/app/models/index.ts
index 3538dbb..74909fc 100644
--- a/app/models/index.ts
+++ b/app/models/index.ts
@@ -1,5 +1,5 @@
-export * from "./extensions/with-environment"
-export * from "./extensions/with-root-store"
-export * from "./root-store/root-store"
-export * from "./root-store/root-store-context"
-export * from "./root-store/setup-root-store"
+export * from './extensions/with-environment'
+export * from './extensions/with-root-store'
+export * from './root-store/root-store'
+export * from './root-store/root-store-context'
+export * from './root-store/setup-root-store'
diff --git a/app/models/root-store/root-store-context.ts b/app/models/root-store/root-store-context.ts
index 537e51c..f01a35c 100644
--- a/app/models/root-store/root-store-context.ts
+++ b/app/models/root-store/root-store-context.ts
@@ -1,5 +1,5 @@
-import { createContext, useContext } from "react"
-import { RootStore } from "./root-store"
+import { createContext, useContext } from 'react'
+import { RootStore } from './root-store'
/**
* Create a context we can use to
diff --git a/app/models/root-store/root-store.ts b/app/models/root-store/root-store.ts
index 1131b48..56425bc 100644
--- a/app/models/root-store/root-store.ts
+++ b/app/models/root-store/root-store.ts
@@ -1,5 +1,5 @@
-import { Instance, SnapshotOut, types } from "mobx-state-tree"
-import { CharacterStoreModel } from "../character-store/character-store"
+import { Instance, SnapshotOut, types } from 'mobx-state-tree'
+import { CharacterStoreModel } from '../character-store/character-store'
/**
* A RootStore model.
diff --git a/app/models/root-store/setup-root-store.ts b/app/models/root-store/setup-root-store.ts
index 4a6d0c5..b1a741b 100644
--- a/app/models/root-store/setup-root-store.ts
+++ b/app/models/root-store/setup-root-store.ts
@@ -1,12 +1,12 @@
-import { onSnapshot } from "mobx-state-tree"
-import { RootStoreModel, RootStore } from "./root-store"
-import { Environment } from "../environment"
-import * as storage from "../../utils/storage"
+import { onSnapshot } from 'mobx-state-tree'
+import { RootStoreModel, RootStore } from './root-store'
+import { Environment } from '../environment'
+import * as storage from '../../utils/storage'
/**
* The key we'll be saving our state as within async storage.
*/
-const ROOT_STATE_STORAGE_KEY = "root"
+const ROOT_STATE_STORAGE_KEY = 'root'
/**
* Setup the environment that all the models will be sharing.
@@ -49,7 +49,9 @@ export async function setupRootStore() {
}
// track changes & save to storage
- onSnapshot(rootStore, (snapshot) => storage.save(ROOT_STATE_STORAGE_KEY, snapshot))
+ onSnapshot(rootStore, (snapshot) =>
+ storage.save(ROOT_STATE_STORAGE_KEY, snapshot),
+ )
return rootStore
}