summaryrefslogtreecommitdiff
path: root/app/models/extensions/with-environment.ts
blob: 9fe5fd5a2314f53ffdea7ac6e8c07cd2137e8577 (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)
    },
  },
})