Rohan Sircar
3 years ago
8 changed files with 56 additions and 65 deletions
-
2src/main/scala/nova/monadic_sfx/MainApp.scala
-
2src/main/scala/nova/monadic_sfx/implicits/JFXButton.scala
-
45src/main/scala/nova/monadic_sfx/implicits/JavaFxMonixObservables.scala
-
4src/main/scala/nova/monadic_sfx/implicits/MenuItem.scala
-
62src/main/scala/nova/monadic_sfx/implicits/package.scala
-
2src/main/scala/nova/monadic_sfx/ui/components/todo/TodoListComponentOld.scala
-
2src/main/scala/nova/monadic_sfx/ui/components/todo/TodoListView.scala
-
2src/main/scala/nova/monadic_sfx/ui/screens/HomeScreen.scala
@ -1,9 +1,7 @@ |
|||
package nova.monadic_sfx.implicits |
|||
|
|||
import nova.monadic_sfx.implicits._ |
|||
import scalafx.scene.{control => sfxc} |
|||
|
|||
import JavaFXMonixObservables._ |
|||
|
|||
class MenuItem extends sfxc.MenuItem { |
|||
def obsAction = new ActionObservableBuilder(this.observableAction) |
|||
} |
@ -1,50 +1,20 @@ |
|||
package nova.monadic_sfx |
|||
|
|||
import javafx.event.ActionEvent |
|||
import monix.execution.Ack |
|||
import monix.execution.Cancelable |
|||
import monix.reactive.Observable |
|||
import monix.reactive.OverflowStrategy |
|||
import scalafx.scene.control._ |
|||
package object implicits |
|||
extends MySfxObservableImplicits |
|||
with JavaFXMonixObservables |
|||
|
|||
package object implicits extends MySfxObservableImplicits { |
|||
// implicit class NodeExt(val node: Node) { |
|||
// def lookup2[T <: SFXDelegate[_]]( |
|||
// selector: String |
|||
// )(implicit c: ClassTag[T]) = { |
|||
// val t = c.runtimeClass |
|||
// Option(node.delegate.lookup(selector)) match { |
|||
// case Some(value) => |
|||
// if (value.getClass == t) Some(value) else None |
|||
// case None => None |
|||
// } |
|||
// } |
|||
|
|||
implicit class MyButtonExt(val button: Button) extends AnyVal { |
|||
def observableAction(): Observable[ActionEvent] = { |
|||
import monix.execution.cancelables.SingleAssignCancelable |
|||
Observable.create(OverflowStrategy.Unbounded) { sub => |
|||
val c = SingleAssignCancelable() |
|||
val l = new javafx.event.EventHandler[ActionEvent] { |
|||
override def handle(event: ActionEvent): Unit = { |
|||
if (sub.onNext(event) == Ack.Stop) c.cancel() |
|||
} |
|||
} |
|||
|
|||
button.onAction = l |
|||
c := Cancelable(() => |
|||
button.removeEventHandler( |
|||
ActionEvent.ACTION, |
|||
l |
|||
) |
|||
) |
|||
c |
|||
} |
|||
} |
|||
} |
|||
|
|||
// implicit class NodeExt(val node: Node) { |
|||
// def lookup2[T <: SFXDelegate[_]]( |
|||
// selector: String |
|||
// )(implicit c: ClassTag[T]) = { |
|||
// val t = c.runtimeClass |
|||
// Option(node.delegate.lookup(selector)) match { |
|||
// case Some(value) => |
|||
// if (value.getClass == t) Some(value) else None |
|||
// case None => None |
|||
// } |
|||
// } |
|||
|
|||
// val x = node.lookup2("") |
|||
// } |
|||
|
|||
} |
|||
// val x = node.lookup2("") |
|||
// } |
Write
Preview
Loading…
Cancel
Save
Reference in new issue