All Downloads are FREE. Search and download functionalities are using the official Maven repository.

reactify.group.GroupReactions.scala Maven / Gradle / Ivy

There is a newer version: 4.1.2
Show newest version
package reactify.group

import reactify.Reactive
import reactify.reaction.{Reaction, Reactions}

class GroupReactions[T, R <: Reactive[T]](group: Group[T, R]) extends Reactions[T] {
  override def +=(reaction: Reaction[T]): Reaction[T] = {
    group.items.foreach(_.reactions += reaction)
    super.+=(reaction)
  }

  override def -=(reaction: Reaction[T]): Boolean = {
    group.items.foreach(_.reactions -= reaction)
    super.-=(reaction)
  }

  override def clear(): Unit = {
    apply().foreach { r =>
      group.items.foreach(_.reactions -= r)
    }
    super.clear()
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy