S-State

Source mirror; https://github.com/g-pechorin/sstate.scala Won’t actually build, use the full repository here Releases (tags) https://github.com/g-pechorin/sstate.scala/tags "com.peterlavalle" %% "sstate" % ??? 'com.peterlavalle:sstate_2.12:???' SState SState is a cute little pure-functional FSM class in Scala that I wrote after seeing JEasyStates. The only real advantage of mine is that it can (probably) be dropped into a Scala.JS project without any magic. There’s a unit test at the foot of this doc showing how I test it.

Scala Extractors

Scala’s extractors and unapply() represent a concept that I haven’t grok’ed until now. Most demonstrations seem to be too long or use the same types everywhere. Here are my thoughts on the concept; val a: C = ??? val i: I = ??? i match { case a(f: O) => ??? } This will try to call the below method class C { def unapply(i: I): Option[O] = ??? } There’s some more flexibility;

(Scala) Delay Run

I wrote a threading primitive and I’m very pleased with it. I plan to wrap all of my “save file” things in this, from now on. Delay Run This class acts as a sort of “once inactive for X do Y” pattern. In my design, I’m wrapping my save actions in it and triggering schedule() after practically every edit. The class is passed a delay: Long value to specify how long to actually wait - I’m using 1.