Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5e5b32f

Browse filesBrowse files
committed
environment docs
1 parent 07bf3a4 commit 5e5b32f
Copy full SHA for 5e5b32f

1 file changed

+44Lines changed: 44 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+44Lines changed: 44 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: Environment
3+
sidebar_position: 3
4+
---
5+
6+
# Environment
7+
8+
An configuration object pushed from the cloud as an observable. The environment can be configured
9+
throug the gateway OpenAPI or the Visual Studio Code extension.
10+
11+
The environment is cached locally in the settings to handle offline scenarios.
12+
13+
```ts
14+
import { environment } from "@devicescript/cloud"
15+
16+
// highlight-next-line
17+
const env = await environment<{ target: number }>()
18+
```
19+
20+
## value
21+
22+
Reads the current value of the environment.
23+
24+
```ts
25+
import { environment } from "@devicescript/cloud"
26+
const env = await environment<{ target: number }>()
27+
28+
// highlight-next-line
29+
const { target } = env.value || {}
30+
```
31+
32+
## subscribe
33+
34+
Subscribes to updates to the environment values.
35+
36+
```ts
37+
import { environment } from "@devicescript/cloud"
38+
const env = await environment<{ target: number }>()
39+
40+
// highlight-next-line
41+
env.subscribe(async ({ target }) => {
42+
console.log(target)
43+
})
44+
```

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.