the value in trees
TRANSCRIPT
THE VALUE IN TREESDREW MCCORMACK
SKETCH
PROBLEMS
▸ Edits during saves
▸ Edits during rendering
▸ Fragile undo
SNAPSHOTTime
1.02.0
VALUE TYPES
PROS
▸ Stack memory
▸ No reference counting
▸ Safe between threads
▸ No changes behind your back
struct Document {
var sections: [Section]
}
struct Section {
var paragraphs: [Paragraph]
}
struct Paragraph {
var style: ParagraphStyle
var content: String
}
class ViewController {
var document: Document {
didSet {
self.reloadViews()
}
}
}
let c = ViewController()
c.document.sections[0].paragraphs[0].style = ...
1.02.0
CAN I HAVE A VALUE STORE FOR XMAS?
…AND CAN I HAVE IT SYNC?
DISTRIBUTED VALUE STORE (DVS)
DISTRIBUTED VALUE STORE (DVS)
Repository
DISTRIBUTED VALUE STORE (DVS)
struct Person { var name = "Bob" var age = 32 var tags = ["clean", "smart"] }
DISTRIBUTED VALUE STORE (DVS)
struct Person { var name = "Bob" var age = 32 var tags = ["clean", "smart"] }
CloudKit Repository
DISTRIBUTED VALUE STORE (DVS)
struct Person { var name = "Bob" var age = 32 var tags = ["clean", "smart"] }
github.com/mentalfaculty/impeller
import Impeller
struct Person: Storable {
static let storedType = "Person"
var metadata = Metadata()
var name = "No Name"
var age: Int? = nil
...
init?(readingFrom repository:ReadRepository) {
name = repository.read("name")!
age = repository.read(optionalFor:"age")!
}
func write(in repository:WriteRepository) {
repository.write(name, for: "name")
repository.write(age, for: "age")
}
ATTRIBUTION
IMAGES▸ Sketch Logo
▸ https://www.sketchappsources.com/free-source/2332-new-sketch-vector-icon.html
▸ Bamboo Forest
▸ https://www.pexels.com/photo/nature-forest-trees-bamboo-5091/
▸ Redwood Forest
▸ https://commons.wikimedia.org/wiki/File:Sequoia_sempervirens_Big_Basin_Redwoods_State_Park_4.jpg
▸ Notes
▸ http://www.cooperazionetrentina.it/Giovani/Iniziative/Iniziative-2015/I-giovani-e-la-cooperazione-che-cambia-7-edizione
▸ Crop Circles
▸ https://commons.wikimedia.org/wiki/File:CropCircleW.jpg
▸ iPhone
▸ https://commons.wikimedia.org/wiki/File:IPhone_with_icons.svg
▸ Database Icon
▸ https://pixabay.com/en/database-diagram-data-storage-disk-29954/
▸ Jedward
▸ https://www.flickr.com/photos/chiropractic/6849052778
▸ No cycling
▸ https://commons.wikimedia.org/wiki/File:Uruguay_Road_Sign_Bicycles_Only.svg
▸ Planting
▸ https://www.flickr.com/photos/usfsregion5/3598029211