NavSet Requests - laforge49/Asynchronous-Functional-Programming GitHub Wiki

SetRequest and GetRequest can be applied to an IncDesNavSet, with the value set or returned an IncDesBoolean. As with IncDesNavMap, the last name in the pathname is the key.

##NavSetTest

val systemServices = SystemServices(new ServicesRootComponentFactory)
val dbName = "IntStringSetNoLog.db"
val file = new java.io.File(dbName)
file.delete
val properties = new Properties
properties.put("dbPathname", dbName)
val db = Subsystem(
  systemServices,
  new SmallNoLogComponentFactory,
  properties = properties,
  actorId = ActorId("db"))
val tru = IncDesBoolean(null)
val fls = IncDesBoolean(null)
val chain = new Chain
chain.op(systemServices, Register(db))
chain.op(db, SetRequest(db, "/$", IncDesStringSet(null, db)))
chain.op(tru, Set(null, true))
chain.op(fls, Set(null, false))
chain.op(db, SetRequest(db, "/$/1", tru))
chain.op(db, SetRequest(db, "/$/2", tru))
chain.op(db, SetRequest(db, "/$/2", fls))
chain.op(db, SetRequest(db, "/$/3", tru))
chain.op(db, SetRequest(db, "/$/10", tru))
chain.op(db, GetRequest(db, "/$/1"), "one")
chain.op(Unit => chain("one"), Value(), "1")
chain.op(db, GetRequest(db, "/$/2"), "two")
chain.op(Unit => chain("two"), Value(), "2")
Future(systemServices, chain)
println(chain.results)
systemServices.close

Output.

{1=true, 
2=false, 
one=org.agilewiki.incDes.IncDesBoolean@30b3f9b8, 
two=org.agilewiki.incDes.IncDesBoolean@77cfb802}

NavSetTest


tutorial