All equality expressions in this document return true:
import OptionalSubscripts
var📦:Any?
📦 =nil
📦 =[]
📦 =[:]📦[]="👋"try📦[]=="👋"📦["one"]=1try📦["one"]==1📦["one",2]=2try📦["one",2]==2📦["one",10]=niltry📦["one"]as[Int?]==[nil,nil,2]📦["one",2]=["three":4]try📦["one",2,"three"]==4try📦[\.["one"][2]["three"]]==4📦["one",2]=nil📦["one"]==nil📦["one","two"]=nil📦[]==nilThe package includes Any?.Store actor with routed streams, publishers, batch updates and atomic transactions:
leto=Any?.Store()letstream=await o.stream("me",2,"you").filter(String.self).prefix(3)Task{varhearts:[String]=[]forawaitoin stream {
hearts.append(o)}
hearts ==["❤️","💛","💚"]}await o.set("me",2,"you", to:"❤️")await o.set("me",2, to:["you":"💛"])await o.set("me", to:[nil,nil,["you":"💚"]])The package also includes Any?.Pond actor that turns a chunky data source (like a document-oriented database) into routed data streams of arbitrary granularity:
letdb=SomeDatabase() // conforms to Geyser protocol and streams entire documents
letpond=Any?.Pond(source: db)await db.store.set("v/2.0/way/to","my","heart", to:"🤍")varhearts=""loop:forawaitheartin pond.stream("way","to","my","heart").filter(String?.self){ // observing a nested field in a versioned document ↑
hearts += heart ??""switch heart {casenilwhere hearts.isEmpty:await db.store.set("v/1.0/way/to","my","heart", to:"❤️")case"❤️":await db.store.set("v/1.0/way/to","my","heart", to:"💛")case"💛":await db.store.set("v/1.0/way/to","my","heart", to:"💚")case"💚":await db.setVersion(to:"v/2.0/")case"🤍":break loop
default:assertionFailure()}}
hearts =="❤️💛💚🤍"await pond.gushSources["v/1.0/way/to"]?.referenceCount ==nilawait pond.gushSources["v/2.0/way/to"]?.referenceCount ==1... where:
protocolGeyser{associatedtypeGushID:HashableassociatedtypeGushes:AsyncSequencewhere Gushes.Element ==Any?associatedtypeGushToRouteMapping:AsyncSequencewhere GushToRouteMapping.Element ==(id:GushID, route:Optional<Any>.Route)?func stream(_ gush:GushID)async->Gushesfunc source<Route>(of route:Route)async->GushToRouteMappingwhere Route:Collection, Route.Index ==Int, Route.Element ==Optional<Any>.Location}And a bunch of other (hopefully) useful new API.
(Decent documentation and an overall statement of purpose is forthcoming 😜)