From fcd7b81323978b02157b22e7d6ad57b8e5842450 Mon Sep 17 00:00:00 2001 From: "Jennifer K. Tran" <38402540+jennifertrin@users.noreply.github.com> Date: Thu, 5 Dec 2024 16:44:42 -0800 Subject: [PATCH] docs: add statement about import and actor sequence (#4688) Add a statement about import and actor sequence based on question related to this forum post: https://forum.dfinity.org/t/misplaced-await-and-misplaced-async/34479 Co-authored-by: Jessie Mongeon <133128541+jessiemongeon1@users.noreply.github.com> Co-authored-by: Luc Blaeser <112870813+luc-blaeser@users.noreply.github.com> --- doc/md/writing-motoko/actors-async.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/md/writing-motoko/actors-async.md b/doc/md/writing-motoko/actors-async.md index 437636d40cd..3d96c9307d4 100644 --- a/doc/md/writing-motoko/actors-async.md +++ b/doc/md/writing-motoko/actors-async.md @@ -32,6 +32,8 @@ In Motoko, actors have dedicated syntax and types: - Waiting on `f` to be completed is expressed using `await f` to obtain a value of type `T`. To avoid introducing shared state through messaging, for example, by sending an object or mutable array, the data that can be transmitted through shared functions is restricted to immutable, shared types. +- All state should be encapsulated within the actor or actor class. The main actor file should begin with imports, followed by the actor or actor class definition. + ## Defining an actor Consider the following actor declaration: