summaryrefslogtreecommitdiff
path: root/app_expo/models/extensions/with-environment.ts
blob: 1fc190eb540fae9d0ef3287db90c49e81d638b44 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { getEnv, IStateTreeNode } from 'mobx-state-tree'
import { Environment } from '../environment'

/**
 * Adds a environment property to the node for accessing our
 * Environment in strongly typed.
 */
export const withEnvironment = (self: IStateTreeNode) => ({
  views: {
    /**
     * The environment.
     */
    get environment() {
      return getEnv<Environment>(self)
    },
  },
})