Skip to content

Commit

Permalink
prepare for release, and updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Dahan committed Jul 6, 2016
1 parent df57914 commit ca5ab89
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ person["lastName"] = "Zuckerberg"
let company = Entity(type: "Company")
company["name"] = "Facebook"

let employee: Relationship = Relationship(type: "Employee")
let employee = Relationship(type: "Employee")
employee["startDate"] = "February 4, 2004"
employee.addToGroup("CEO")
employee.addToGroup("Founder")
Expand Down Expand Up @@ -126,12 +126,12 @@ let book2 = Entity(type: "Book")
book2["title"] = "The Holographic Universe"
book2.addToGroup("Physics")

let purchase = Action(type: "Purchase")
purchase.addToGroup("Pending")
let purchased = Action(type: "Purchased")
purchased.addToGroup("Pending")

purchase.addSubject(user)
purchase.addObject(book1)
purchase.addObject(book2)
purchased.addSubject(user)
purchased.addObject(book1)
purchased.addObject(book2)

graph.sync()
```
Expand All @@ -141,32 +141,32 @@ graph.sync()
<a name="data-driven"></a>
## Data Driven

As data moves through your application, the state of information may be observed to create a reactive experience. Below is an example of watching when a "User purchases a book".
As data moves through your application, the state of information may be observed to create a reactive experience. Below is an example of watching when a "User Clicked a Button".

```swift
// Set the UIViewController's Protocol to GraphDelegate.
// Set Protocol to GraphDelegate.

let graph = Graph()
graph.delegate = self

graph.watchForAction(types: ["Purchased"])
graph.watchForAction(types: ["Clicked"])

let user = Entity(type: "User")
let purchased = Action(type: "Purchased")
let book = Entity(type: "Book")
let user: Entity = Entity(type: "User")
let clicked = Action(type: "Clicked")
let button = Entity(type: "Button")

purchased.addSubject(user)
purchased.addObject(book)
clicked.addSubject(user)
clicked.addObject(button)

graph.sync()
graph.save()

// Delegate method.
func graphDidInsertAction(graph: Graph, action: Action) {
switch(action.type) {
case "Clicked":
print(action.subjects.first?.type) // User
print(action.objects.first?.type) // Button
case "Purchased":
case "Swiped":
// Handle swipe.
default:break
}
Expand Down

0 comments on commit ca5ab89

Please sign in to comment.