Skip to content

Commit

Permalink
feat(docs): update docs (#539)
Browse files Browse the repository at this point in the history
feat(docs): update docs

Updates the Wing docs. See details in [workflow run].

[Workflow Run]: https://github.com/winglang/docsite/actions/runs/5578562682

------

*Automatically created via the "update-docs" workflow*
  • Loading branch information
monadabot authored Jul 17, 2023
1 parent aefc175 commit e086266
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ While inflight code can't call preflight code, it's perfectly ok to reference da
For example, the `cloud.Api` class has a preflight field named `url`.
Since it's a piece of static data, it can be directly referenced inflight:

```js playground
```js
bring cloud;
bring http;

Expand Down Expand Up @@ -259,7 +259,8 @@ names.push("Jack"); // OK

inflight () => {
count = count + 1; // error: Variable cannot be reassigned from inflight
names.push("Jill"); // error: variable "names" cannot be mutated in inflight
names.push("Jill"); // error: variable "names" cannot be mutated in inflight - error message not
// implemented yet, see https://github.com/winglang/wing/issues/3069
};
```

Expand Down
2 changes: 1 addition & 1 deletion versioned_docs/version-latest/03-language-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ The loop invariant in for loops is implicitly re-assignable (`var`).
> for item in arr {
> log("${item}");
> }
> for item: num in set {
> for item in set {
> log("${item}");
> }
> for item in 0..100 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The following example shows a complete REST API implementation using `cloud.Api`

```ts playground
bring cloud;
bring ex;

let api = new cloud.Api();
// Used for generating unique id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ bucket.addObject("my-file.txt", "Hello, world!");

### Using a bucket inflight

```js
```js playground
bring cloud;

let bucket = new cloud.Bucket();

inflight () => {
let bucketFunc = inflight () => {
bucket.put("file.txt", "Hello, world!");
bucket.putJson("person.json", Json { name: "Alice" });

Expand All @@ -69,6 +69,8 @@ inflight () => {

bucket.delete("file.txt");
};

new cloud.Function(bucketFunc);
```

### Run code on bucket events
Expand All @@ -78,7 +80,9 @@ Use the `onEvent` method for responding to any event.

Each method creates a new `cloud.Function` resource which will be triggered by the given event type.

```js
```js playground
bring cloud;

let store = new cloud.Bucket();
let copies = new cloud.Bucket() as "Backup";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ let counter = new cloud.Counter(

### Using a counter inflight

```js
```js playground
bring cloud;

let counter = new cloud.Counter();

inflight () => {
let counterFunc = inflight () => {
let prev = counter.inc(); // increment by 1 and return previous value
counter.inc(5); // increment by 5
counter.dec(); // decrement by 1
Expand All @@ -45,6 +45,8 @@ inflight () => {

counter.set(100); // set to a specific value
};

new cloud.Function(counterFunc);
```

### Using keys to manage multiple counter values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bring cloud;
let q = new cloud.Queue();

q.setConsumer(inflight (m: str) => {
log("messgae ${m} consumed")
log("message ${m} consumed");
});

new cloud.Function(inflight () => {
Expand Down

1 comment on commit e086266

@vercel
Copy link

@vercel vercel bot commented on e086266 Jul 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.