Skip to content

Commit

Permalink
Update playgrounds
Browse files Browse the repository at this point in the history
  • Loading branch information
srdanrasic committed Mar 31, 2019
1 parent e7101d5 commit 66fee37
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ class Contact: NSObject {
var contact: Contact! = Contact()
weak var weakTest: Contact? = contact

contact.reactive.keyPath(\.name).observeNext { event in
print(event)
contact.reactive.keyPath("name", ofType: String?.self, context: .main).observeNext { event in
print(event ?? "nil")
}

contact.name = "jim"
contact.name = nil
contact.name = "james"

SafeSignal.just("j").bind(to: contact, keyPath: \.name, context: .immediate)
SafeSignal(just: "j").bind(to: contact, keyPath: \.name, context: .immediate)

contact = nil
assert(weakTest == nil)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ dictionary["B"] = 2

// Custom collection - Data

let data = MutableObservableCollection(Data(bytes: [0x0A, 0x0B]))
let data = MutableObservableCollection(Data([0x0A, 0x0B]))

data.observeNext { (changeset) in
print(changeset.collection, changeset.diff, changeset.patch)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@ PlaygroundPage.current.liveView = tableView
PlaygroundPage.current.needsIndefiniteExecution = true

// A signal that emits a value every 1 second
let pulse = SafeSignal<Int>.interval(1)
let pulse = SafeSignal(sequence: 0..., interval: 1)

// A signal of [String]
let data = SafeSignal
.sequence([
let data = SafeSignal(sequence: [
["A"],
["A", "B", "C"],
["A", "C"],
Expand Down
2 changes: 1 addition & 1 deletion Playground-iOS.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='raw' executeOnSourceChanges='false'>
<playground version='6.0' target-platform='ios' display-mode='raw'>
<pages>
<page name='Observable Collections'/>
<page name='UITableView+Signal+Diff'/>
Expand Down

0 comments on commit 66fee37

Please sign in to comment.