From 5ae06038ffe150638ac472e4c643fdee6dd202d6 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 21 Sep 2022 12:46:08 -0400 Subject: Update README.md --- README.md | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index c1c8d1b..1d7357d 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,17 @@ 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) { +graffiti.logIn() +graffiti.logOut() +if (graffiti.loggedIn) { // ... } // 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 +45,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 +64,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) ``` -- cgit v1.2.3-70-g09d2 From e8fea737dd6baaca9ddcb3917af1af08729bd938 Mon Sep 17 00:00:00 2001 From: anonymous Date: Wed, 21 Sep 2022 12:46:08 -0400 Subject: Update README.md --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1d7357d..4c27ffa 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,8 @@ const queryID = await graffiti.subscribe({ // And then unsubscribe to those queries await graffiti.unsubscribe(queryID) -// You can log in and out and check your logged-in status -graffiti.logIn() -graffiti.logOut() -if (graffiti.loggedIn) { - // ... -} +// You can toggle logging in and out +graffiti.toggleLogIn() // When you are logged in you can reference your user ID console.log(graffiti.myID) -- cgit v1.2.3-70-g09d2