summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoranonymous2022-09-21 12:46:08 -0400
committeranonymous2022-09-21 12:46:08 -0400
commit09a699044d6dc71941b175c4435c19d227633945 (patch)
treed7ba4fcb6c6882091ecddc1e0129fce5783e9a01
parentc35d4f96a092e8526238762fecbd604ce048ff8a (diff)
parente8fea737dd6baaca9ddcb3917af1af08729bd938 (diff)
Merge branch 'main' of github.com:csail-graffiti/graffiti-js-vanilla
-rw-r--r--README.md37
1 files changed, 16 insertions, 21 deletions
diff --git a/README.md b/README.md
index c1c8d1b..4c27ffa 100644
--- a/README.md
+++ b/README.md
@@ -1,19 +1,19 @@
# Graffiti for Vanilla Javascript
This is the base Javascript library that interfaces with the [Graffiti server](https://github.com/csail-graffiti/server).
-We recommend not using this vanilla library itself but instead using framework plugins that are built on top of it like the [Graffiti plugin for Vue.JS](https://github.com/csail-graffiti/graffiti-js-vue).
+We recommend not using this vanilla library itself but instead using framework plugins that are built on top of it like the [Graffiti plugin for Vue.JS](https://github.com/csail-graffiti/graffiti-x-vue).
Example usage:
```javascript
-import GraffitiSocket from "https://csail-graffiti.github.io/graffiti-js-vanilla/socket.js"
+import Graffiti from "https://csail-graffiti.github.io/graffiti-x-js/graffiti.js"
// You can initialize a connection to the graffiti server
-const gs = GraffitiSocket()
-await gs.initialize()
+const graffiti = Graffiti()
+await graffiti.initialize()
// You can subscribe to queries
-const queryID = await gs.subscribe({
+const queryID = await graffiti.subscribe({
type: 'post',
content: { $type: 'string' }
}
@@ -24,17 +24,13 @@ const queryID = await gs.subscribe({
)
// And then unsubscribe to those queries
-await gs.unsubscribe(queryID)
+await graffiti.unsubscribe(queryID)
-// You can log in and out and check your logged-in status
-gs.logIn()
-gs.logOut()
-if (gs.loggedIn) {
- // ...
-}
+// You can toggle logging in and out
+graffiti.toggleLogIn()
// When you are logged in you can reference your user ID
-console.log(gs.myID)
+console.log(graffiti.myID)
// And when you are logged in you can
// create objects,
@@ -45,15 +41,15 @@ const myCoolPost = {
// ("completing" an object annotates
// it with your user ID and a random
// object ID, required by the server)
-gs.complete(myCoolPost)
-await gs.update(myCoolPost, {})
+graffiti.complete(myCoolPost)
+await graffiti.update(myCoolPost, {})
// replace objects,
myCoolPost.content += '!!!'
-await gs.update(myCoolPost, {})
+await graffiti.update(myCoolPost, {})
// and remove objects.
-await gs.remove(myCoolPost)
+await graffiti.remove(myCoolPost)
// The second argument in the update
// function is a query. If the object you
@@ -64,10 +60,9 @@ await gs.remove(myCoolPost)
const query = { type: 'post' }
const myPost = { type: 'post' }
const myNotPost = { type: 'notpost' }
-gs.complete(myNotPost)
+graffiti.complete(myNotPost)
// This works
-await gs.update(myPost, query)
+await graffiti.update(myPost, query)
// But this won't work!
-await gs.update(myNotPost, query)
-
+await graffiti.update(myNotPost, query)
```