Skip to content

Commit cb4fc3f

Browse files
Merge pull request #1183 from dfinity/jessiemongeon1-patch-14
add: Deploy to ICP Ninja + Standardize README
2 parents ab75aed + 724ab14 commit cb4fc3f

File tree

1 file changed

+9
-43
lines changed

1 file changed

+9
-43
lines changed

motoko/pub-sub/README.md

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,24 @@ This sample project demonstrates how functions may be passed as arguments of int
44

55
A common problem in both distributed and decentralized systems is keeping separate services (or canisters) synchronized with one another. While there are many potential solutions to this problem, a popular one is the publisher/subscriber pattern or "PubSub". PubSub is an especially valuable pattern on the Internet Computer as its primary drawback, message delivery failures, does not apply.
66

7-
## Prerequisites
8-
This example requires an installation of:
7+
## Deploying from ICP Ninja
98

10-
- [x] Install the [IC SDK](https://internetcomputer.org/docs/current/developer-docs/setup/install/index.mdx).
11-
- [x] Clone the example dapp project: `git clone https://github.com/dfinity/examples`
9+
[![](https://icp.ninja/assets/open.svg)](https://icp.ninja/editor?g=https://github.com/dfinity/examples/tree/master/motoko/pub-sub)
1210

13-
Begin by opening a terminal window.
11+
## Build and deploy from the command-line
1412

15-
## Step 1: Setup the project environment
13+
### 1. [Download and install the IC SDK.](https://internetcomputer.org/docs/building-apps/getting-started/install)
1614

17-
Navigate into the folder containing the project's files and start a local instance of the Internet Computer with the commands:
15+
### 2. Download your project from ICP Ninja using the 'Download files' button on the upper left corner, or [clone the GitHub examples repository.](https://github.com/dfinity/examples/)
1816

19-
```bash
20-
cd examples/motoko/pub-sub
21-
dfx start --background
22-
```
17+
### 3. Navigate into the project's directory.
2318

24-
## Step 2: Deploy the canisters:
19+
### 4. Deploy the project to your local environment:
2520

26-
```bash
27-
dfx deploy
2821
```
29-
30-
## Step 3: Subscribe to the "Apples" topic
31-
32-
```bash
33-
dfx canister call sub init '("Apples")'
34-
```
35-
36-
## Step 4: Publish to the "Apples" topic
37-
38-
```bash
39-
dfx canister call pub publish '(record { "topic" = "Apples"; "value" = 2 })'
40-
```
41-
42-
## Step 5: Receive your subscription
43-
44-
```bash
45-
dfx canister call sub getCount
46-
```
47-
48-
The output should resemble the following:
49-
50-
```bash
51-
(2 : nat)
22+
dfx start --background --clean && dfx deploy
5223
```
5324

5425
## Security considerations and best practices
5526

56-
If you base your application on this example, we recommend you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/current/references/security/) for developing on the Internet Computer. This example may not implement all the best practices.
57-
58-
For example, the following aspects are particularly relevant for this app, since it makes inter-canister calls:
59-
* [Be aware that state may change during inter-canister calls.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview)
60-
* [Only make inter-canister calls to trustworthy canisters.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview)
61-
* [Don’t panic after await and don’t lock shared resources across await boundaries.](https://internetcomputer.org/docs/current/developer-docs/security/security-best-practices/overview)
27+
If you base your application on this example, it is recommended that you familiarize yourself with and adhere to the [security best practices](https://internetcomputer.org/docs/building-apps/security/overview) for developing on ICP. This example may not implement all the best practices.

0 commit comments

Comments
 (0)