Skip to content

Commit

Permalink
remove deprecations (outwatch#780)
Browse files Browse the repository at this point in the history
* remove deprecations

* update colibri

* let EmitterBuilder#asEffect use call by name

* format code

* fix deprecation in docs
  • Loading branch information
cornerman authored Jun 22, 2024
1 parent 77b336c commit 1686dba
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 318 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ inThisBuild(
)

val jsdomVersion = "13.2.0"
val colibriVersion = "0.8.4"
val colibriVersion = "0.8.6"

val isDotty = Def.setting(CrossVersion.partialVersion(scalaVersion.value).exists(_._1 == 3))
lazy val commonSettings = Seq(
Expand Down
4 changes: 2 additions & 2 deletions docs/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -1011,10 +1011,10 @@ VMod.managedElement.asSvg { (elem: svg.Element) => ???; Cancelable(() => ???) }

### Custom EmitterBuilders

You can `combine`, `map`, `collect`, `filter` and `transform` `EmitterBuilder`:
You can `merge`, `map`, `collect`, `filter` and `transform` `EmitterBuilder`:

```scala mdoc:js:compile-only
button(EmitterBuilder.combine(onMouseUp.as(false), onMouseDown.as(true)).foreach { isDown => println("Button is down? " + isDown) })
button(EmitterBuilder.merge(onMouseUp.as(false), onMouseDown.as(true)).foreach { isDown => println("Button is down? " + isDown) })
// this is the same as: button(EmitterBuilder.combine(onMouseUp.map(_ => false), onMouseDown.map(_ => true)).foreach { isDown => println("Button is down? " + isDown })
```

Expand Down
15 changes: 0 additions & 15 deletions outwatch/src/main/scala/outwatch/AttrBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ trait AttrBuilder[-T, +A] extends Any {

final def assign(value: Option[T]): Option[A] = value.map(assign)

@deprecated("Use assign instead", "")
final def assignOption(value: Option[T]): Option[A] = assign(value)

@inline final def :=(value: T): A = assign(value)
@inline final def :=(value: Option[T]): Option[A] = assign(value)

Expand All @@ -20,11 +17,6 @@ trait AttrBuilder[-T, +A] extends Any {
source: F[T2],
@annotation.unused dummy: Unit = (),
): Observable[Option[A]] = Observable.lift(source).map(assign)

@deprecated("Use := instead", "")
final def :=?(value: Option[T]): Option[A] = :=(value)
@deprecated("Use <-- instead", "")
final def <--?[F[_]: Source, T2 <: Option[T]](source: F[T2]): Observable[Option[A]] = <--(source)
}

object AttrBuilder {
Expand Down Expand Up @@ -97,13 +89,6 @@ object AttrBuilder {
extends AttrBuilder[T, AccumStyle] {
def assign(value: T): AccumStyle = AccumStyle(name, value.toString, reducer)
}

implicit class VModOps[T](private val self: AttrBuilder[T, VMod]) extends AnyVal {
@deprecated("Use observable operators instead", "")
def toggle(value: T): AttrBuilder[Boolean, VMod] = AttrBuilder.ofModifier { enabled =>
if (enabled) self.assign(value) else VMod.empty
}
}
}

object KeyBuilder {
Expand Down
124 changes: 9 additions & 115 deletions outwatch/src/main/scala/outwatch/EmitterBuilder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,42 +44,19 @@ trait EmitterBuilder[+O, +R] extends AttrBuilder[O => Unit, R] {
@inline final def -->(sink: Observer[O]): R = forwardTo(sink)
@inline final def -->[F[_]: Sink, O2 >: O](sink: F[O2], @annotation.nowarn dummy: Unit = ()): R = forwardTo(sink)

@deprecated("Use .done instead", "")
@inline final def discard: R = forwardTo(Observer.empty)
@inline final def done: R = forwardTo(Observer.empty)
@inline final def done: R = forwardTo(Observer.empty)

@inline final def foreach(action: O => Unit): R = forwardTo(Observer.create(action))
@deprecated("Use .doAction(action) instead", "")
@inline final def foreach(action: => Unit): R = doAction(action)
@inline final def doAction(action: => Unit): R = foreach(_ => action)
@inline final def doAction(action: => Unit): R = foreach(_ => action)

@inline final def assign(action: O => Unit): R = foreach(action)

@deprecated("Use .foreachEffect(action) instead", "")
@inline final def foreachSync[G[_]: RunSyncEffect](action: O => G[Unit]): R = mapSync(action).done
@deprecated("Use .doEffect(action) instead", "")
@inline final def doSync[G[_]: RunSyncEffect](action: G[Unit]): R = foreachSync(_ => action)

@deprecated("Use .foreachEffect(action) instead", "")
@inline def foreachAsync[G[_]: RunEffect](action: O => G[Unit]): R = foreachEffect(action)
@deprecated("Use .doEffect(action) instead", "")
@inline def doAsync[G[_]: RunEffect](action: G[Unit]): R = doEffect(action)

@inline def foreachEffect[G[_]: RunEffect](action: O => G[Unit]): R = mapEffect(action).done
@inline def doEffect[G[_]: RunEffect](action: => G[Unit]): R = foreachEffect(_ => action)

@inline def foreachFuture(action: O => Future[Unit]): R = mapFuture(action).done
@inline def doFuture(action: => Future[Unit]): R = foreachFuture(_ => action)

@deprecated("Use .foreachSingleEffect(action) instead", "")
@inline def foreachAsyncSingleOrDrop[G[_]: RunEffect](action: O => G[Unit]): R = foreachSingleEffect(action)
@deprecated("Use .doSingleEffect(action) instead", "")
@inline def doAsyncSingleOrDrop[G[_]: RunEffect](action: G[Unit]): R = doSingleEffect(action)
@deprecated("Use .foreachSingleEffect(action) instead", "")
@inline def foreachEffectSingleOrDrop[G[_]: RunEffect](action: O => G[Unit]): R = foreachSingleEffect(action)
@deprecated("Use .doSingleEffect(action) instead", "")
@inline def doEffectSingleOrDrop[G[_]: RunEffect](action: G[Unit]): R = doSingleEffect(action)

@inline def foreachSingleEffect[G[_]: RunEffect](action: O => G[Unit]): R =
singleMapEffect(action).done
@inline def doSingleEffect[G[_]: RunEffect](action: G[Unit]): R =
Expand Down Expand Up @@ -143,60 +120,25 @@ trait EmitterBuilder[+O, +R] extends AttrBuilder[O => Unit, R] {

@inline final def void: EmitterBuilder[Unit, R] = as(())

@deprecated("Use .as(value) instead", "")
@inline final def use[T](value: T): EmitterBuilder[T, R] = as(value)
@deprecated("Use .asEval(value) instead", "")
@inline final def useLazy[T](value: => T): EmitterBuilder[T, R] = asEval(value)

@deprecated("Use .asEval(value) instead", "")
@inline final def mapTo[T](value: => T): EmitterBuilder[T, R] = asEval(value)
@deprecated("Use .as(value) instead", "")
@inline final def apply[T](value: T): EmitterBuilder[T, R] = as(value)
@deprecated("Use .mapFuture(f) instead", "")
@inline final def concatMapFuture[T](f: O => Future[T]): EmitterBuilder[T, R] = mapFuture(f)
@deprecated("Use .mapEffect(f) instead", "")
@inline final def concatMapAsync[G[_]: RunEffect, T](f: O => G[T]): EmitterBuilder[T, R] = mapEffect(f)

@deprecated("Use .asEffect(value) instead", "")
@inline final def useSync[G[_]: RunSyncEffect, T](value: G[T]): EmitterBuilder[T, R] =
transform(_.mapEffect(_ => value))

@deprecated("Use .asEffect(value) instead", "")
@inline final def useAsync[G[_]: RunEffect, T](value: G[T]): EmitterBuilder[T, R] = asEffect(value)
@inline final def asEffect[G[_]: RunEffect, T](value: G[T]): EmitterBuilder[T, R] = mapEffect(_ => value)
@inline final def asEffect[G[_]: RunEffect, T](value: => G[T]): EmitterBuilder[T, R] = mapEffect(_ => value)
@inline final def withEffect[G[_]: RunEffect: Functor, T](value: G[T]): EmitterBuilder[(O, T), R] =
mapEffect(x => Functor[G].map(value)(x -> _))

@deprecated("Use .asFuture(value) instead", "")
@inline final def useFuture[T](value: => Future[T]): EmitterBuilder[T, R] = asFuture(value)
@inline final def asFuture[T](value: => Future[T]): EmitterBuilder[T, R] = mapFuture(_ => value)
@inline final def asFuture[T](value: => Future[T]): EmitterBuilder[T, R] = mapFuture(_ => value)
@inline final def withFuture[T](value: => Future[T]): EmitterBuilder[(O, T), R] =
mapFuture(x => value.map(x -> _)(ExecutionContext.parasitic))

@deprecated("Use .asSingleEffect(value) instead", "")
@inline final def useAsyncSingleOrDrop[G[_]: RunEffect, T](value: G[T]): EmitterBuilder[T, R] = asSingleEffect(value)
@deprecated("Use .asSingleEffect(value) instead", "")
@inline final def asEffectSingleOrDrop[G[_]: RunEffect, T](value: G[T]): EmitterBuilder[T, R] = asSingleEffect(value)
@deprecated("Use .withSingleEffect(value) instead", "")
@inline final def withEffectSingleOrDrop[G[_]: RunEffect: Functor, T](value: G[T]): EmitterBuilder[(O, T), R] =
withSingleEffect(value)

@inline final def asSingleEffect[G[_]: RunEffect, T](value: G[T]): EmitterBuilder[T, R] =
@inline final def asSingleEffect[G[_]: RunEffect, T](value: => G[T]): EmitterBuilder[T, R] =
singleMapEffect(_ => value)
@inline final def withSingleEffect[G[_]: RunEffect: Functor, T](value: G[T]): EmitterBuilder[(O, T), R] =
singleMapEffect(x => Functor[G].map(value)(x -> _))

@deprecated("Use .asSingleFuture(value) instead", "")
@inline final def useFutureSingleOrDrop[T](value: => Future[T]): EmitterBuilder[T, R] = asSingleFuture(value)
@deprecated("Use .asSingleFuture(value) instead", "")
@inline final def asFutureSingleOrDrop[T](value: => Future[T]): EmitterBuilder[T, R] = asSingleFuture(value)

@inline final def asSingleFuture[T](value: => Future[T]): EmitterBuilder[T, R] =
singleMapFuture(_ => value)
@inline final def withSingleFuture[T](value: => Future[T]): EmitterBuilder[(O, T), R] =
withSingleEffect(IO.fromFuture(IO(value)))

@inline final def asSwitchEffect[G[_]: RunEffect, T](value: G[T]): EmitterBuilder[T, R] =
@inline final def asSwitchEffect[G[_]: RunEffect, T](value: => G[T]): EmitterBuilder[T, R] =
switchMapEffect(_ => value)
@inline final def withSwitchEffect[G[_]: RunEffect: Functor, T](value: G[T]): EmitterBuilder[(O, T), R] =
switchMapEffect(x => Functor[G].map(value)(x -> _))
Expand All @@ -206,7 +148,7 @@ trait EmitterBuilder[+O, +R] extends AttrBuilder[O => Unit, R] {
@inline final def withSwitchFuture[T](value: => Future[T]): EmitterBuilder[(O, T), R] =
withSwitchEffect(IO.fromFuture(IO(value)))

@inline final def asParEffect[G[_]: RunEffect, T](value: G[T]): EmitterBuilder[T, R] =
@inline final def asParEffect[G[_]: RunEffect, T](value: => G[T]): EmitterBuilder[T, R] =
parMapEffect(_ => value)
@inline final def withParEffect[G[_]: RunEffect: Functor, T](value: G[T]): EmitterBuilder[(O, T), R] =
parMapEffect(x => Functor[G].map(value)(x -> _))
Expand All @@ -218,8 +160,6 @@ trait EmitterBuilder[+O, +R] extends AttrBuilder[O => Unit, R] {

@inline final def apply[G[_]: Source, T](source: G[T]): EmitterBuilder[T, R] = asLatest(source)

@deprecated("Use .asLatest(value) instead", "")
@inline final def useLatest[F[_]: Source, T](latest: F[T]): EmitterBuilder[T, R] = asLatest(latest)
@inline final def asLatest[F[_]: Source, T](latest: F[T]): EmitterBuilder[T, R] =
transform[T](source => source.withLatestMap(Observable.lift(latest))((_, u) => u))

Expand All @@ -241,16 +181,12 @@ trait EmitterBuilder[+O, +R] extends AttrBuilder[O => Unit, R] {
def scan[T](seed: T)(f: (T, O) => T): EmitterBuilder[T, R] =
transform[T](source => source.scan(seed)(f))

@deprecated("Use .asScan(seed)(f) instead", "")
@inline final def useScan[T](seed: T)(f: T => T): EmitterBuilder[T, R] = asScan(seed)(f)
@inline final def asScan[T](seed: T)(f: T => T): EmitterBuilder[T, R] = scan(seed)((t, _) => f(t))
@inline final def asScan[T](seed: T)(f: T => T): EmitterBuilder[T, R] = scan(seed)((t, _) => f(t))

def scan0[T](seed: T)(f: (T, O) => T): EmitterBuilder[T, R] =
transform[T](source => source.scan0(seed)(f))

@deprecated("Use .asScan0(seed)(f) instead", "")
@inline final def useScan0[T](seed: T)(f: T => T): EmitterBuilder[T, R] = asScan0(seed)(f)
@inline final def asScan0[T](seed: T)(f: T => T): EmitterBuilder[T, R] = scan0(seed)((t, _) => f(t))
@inline final def asScan0[T](seed: T)(f: T => T): EmitterBuilder[T, R] = scan0(seed)((t, _) => f(t))

def debounce(duration: FiniteDuration): EmitterBuilder[O, R] =
transform[O](source => source.debounce(duration))
Expand All @@ -272,24 +208,14 @@ trait EmitterBuilder[+O, +R] extends AttrBuilder[O => Unit, R] {
def delayMillis(millis: Int): EmitterBuilder[O, R] =
transform[O](source => source.delayMillis(millis))

@deprecated("Use .mapEffect(f) instead", "")
def mapAsync[G[_]: RunEffect, T](f: O => G[T]): EmitterBuilder[T, R] = mapEffect(f)
def mapEffect[G[_]: RunEffect, T](f: O => G[T]): EmitterBuilder[T, R] =
transform[T](source => source.mapEffect(f))

def mapFuture[T](f: O => Future[T]): EmitterBuilder[T, R] = transform[T](source => source.mapFuture(f))

@deprecated("Use .singleMapFuture(f) instead", "")
def mapFutureSingleOrDrop[T](f: O => Future[T]): EmitterBuilder[T, R] = singleMapFuture(f)

def singleMapFuture[T](f: O => Future[T]): EmitterBuilder[T, R] =
transform[T](source => source.singleMapFuture(f))

@deprecated("Use .singleMapEffect(f) instead", "")
def mapAsyncSingleOrDrop[G[_]: RunEffect, T](f: O => G[T]): EmitterBuilder[T, R] = singleMapEffect(f)
@deprecated("Use .singleMapEffect(f) instead", "")
def mapEffectSingleOrDrop[G[_]: RunEffect, T](f: O => G[T]): EmitterBuilder[T, R] = singleMapEffect(f)

def singleMapEffect[G[_]: RunEffect, T](f: O => G[T]): EmitterBuilder[T, R] =
transform[T](source => source.singleMapEffect(f))

Expand All @@ -305,18 +231,6 @@ trait EmitterBuilder[+O, +R] extends AttrBuilder[O => Unit, R] {
def parMapEffect[G[_]: RunEffect, T](f: O => G[T]): EmitterBuilder[T, R] =
transform[T](source => source.parMapEffect(f))

@deprecated("Use .mapEffect(f) instead", "")
def mapSync[G[_]: RunSyncEffect, T](f: O => G[T]): EmitterBuilder[T, R] =
transform[T](source => source.mapEffect(f))

@deprecated("Use transform instead", "1.0.0")
def transformLifted[F[_]: Source: LiftSource, OO >: O, T](f: F[OO] => F[T]): EmitterBuilder[T, R] =
transform[T]((s: Observable[OO]) => Observable.lift(f(LiftSource[F].lift(s))))

@deprecated("Use transform instead", "1.0.0")
def transformLift[F[_]: Source, T](f: Observable[O] => F[T]): EmitterBuilder[T, R] =
transform[T]((s: Observable[O]) => Observable.lift(f(s)))

@inline def mapResult[S](f: R => S): EmitterBuilder[O, S] =
new EmitterBuilder.MapResult[O, R, S](this, f)
}
Expand Down Expand Up @@ -397,16 +311,6 @@ object EmitterBuilder {
Emitter(eventType, e => sink.unsafeOnNext(e.asInstanceOf[E]))
}

@deprecated("Use EmitterBuilder.merge instead", "0.11.0")
@inline def combine[T, R: SubscriptionOwner: SyncEmbed: Monoid](
builders: EmitterBuilder[T, R]*,
): EmitterBuilder[T, R] = mergeIterable(builders)

@deprecated("Use EmitterBuilder.mergeIterable instead", "0.11.0")
def combineSeq[T, R: SubscriptionOwner: SyncEmbed: Monoid](
builders: Seq[EmitterBuilder[T, R]],
): EmitterBuilder[T, R] = mergeIterable(builders)

@inline def merge[T, R: SubscriptionOwner: SyncEmbed: Monoid](
builders: EmitterBuilder[T, R]*,
): EmitterBuilder[T, R] = mergeIterable(builders)
Expand All @@ -415,12 +319,6 @@ object EmitterBuilder {
builders: Iterable[EmitterBuilder[T, R]],
): EmitterBuilder[T, R] = new Custom[T, R](sink => Monoid[R].combineAll(builders.map(_.forwardTo(sink))))

@deprecated("Use EmitterBuilder.fromEvent[E] instead", "0.11.0")
@inline def apply[E <: dom.Event](eventType: String): EmitterBuilder[E, VMod] = fromEvent[E](eventType)
@deprecated("Use EmitterBuilder[E, O] instead", "0.11.0")
@inline def custom[E, R: SubscriptionOwner: SyncEmbed](create: Observer[E] => R): EmitterBuilder[E, R] =
apply[E, R](create)

implicit def monoid[T, R: SubscriptionOwner: SyncEmbed: Monoid]: Monoid[EmitterBuilder[T, R]] =
new Monoid[EmitterBuilder[T, R]] {
def empty: EmitterBuilder[T, R] = EmitterBuilder.emptyOf[R]
Expand Down Expand Up @@ -474,10 +372,6 @@ object EmitterBuilder {
@inline def asLatestEmitter[T](emitter: EmitterBuilder[T, R]): EmitterBuilder[T, SyncIO[R]] =
withLatestEmitter(emitter).map(_._2)

@deprecated("Use asLatestEmitter(emitter) instead", "")
@inline def useLatestEmitter[T](emitter: EmitterBuilder[T, R]): EmitterBuilder[T, SyncIO[R]] =
asLatestEmitter(emitter)

@inline def merge[T >: O](emitter: EmitterBuilder[T, R]): EmitterBuilder[T, R] =
EmitterBuilder.merge(builder, emitter)
}
Expand Down
10 changes: 1 addition & 9 deletions outwatch/src/main/scala/outwatch/VMod.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ object VMod {
Source[F].unsafeSubscribe(source)(Observer.empty),
)

@deprecated("Use managedEval(subscription) instead", "")
@inline def managedFunction[T: CanCancel](subscription: () => T): VMod = managedEval(subscription())
def managedEval[T: CanCancel](subscription: => T): VMod = CancelableModifier(() => Cancelable.lift(subscription))
def managedEval[T: CanCancel](subscription: => T): VMod = CancelableModifier(() => Cancelable.lift(subscription))

object managedElement {
def apply[T: CanCancel](subscription: dom.Element => T): VMod = VMod.eval {
Expand Down Expand Up @@ -105,8 +103,6 @@ object VMod {
@inline def fromEither[T: Render](modifier: Either[Throwable, T]): VMod = modifier.fold(raiseError(_), apply(_))
@inline def evalEither[T: Render](modifier: => Either[Throwable, T]): VMod =
SyncEffectModifier(() => fromEither(modifier))
@deprecated("Use VMod.eval instead", "1.0.0")
@inline def delay[T: Render](modifier: => T): VMod = eval(modifier)
@inline def eval[T: Render](modifier: => T): VMod = SyncEffectModifier(() => modifier)
@inline def composite(modifiers: Iterable[VMod]): VMod = CompositeModifier(modifiers.toJSArray)
@inline def raiseError(error: Throwable): VMod = ErrorModifier(error)
Expand All @@ -116,10 +112,6 @@ object VMod {
@inline def configured(modifier: VMod)(configure: RenderConfig => RenderConfig): VMod =
ConfiguredModifier(modifier, configure)

@deprecated("Use VMod.when(condition)(...) instead", "")
@inline def ifTrue(condition: Boolean): ModifierBooleanOps = when(condition)
@deprecated("Use VMod.whenNot(condition)(...) instead", "")
@inline def ifNot(condition: Boolean): ModifierBooleanOps = whenNot(condition)
@inline def when(condition: Boolean): ModifierBooleanOps = new ModifierBooleanOps(condition)
@inline def whenNot(condition: Boolean): ModifierBooleanOps = new ModifierBooleanOps(!condition)

Expand Down
12 changes: 3 additions & 9 deletions outwatch/src/main/scala/outwatch/definitions/DomTypes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,13 @@ trait Tags
extends tags.EmbedTags[BuilderTypes.HtmlTag] with tags.GroupingTags[BuilderTypes.HtmlTag]
with tags.TextTags[BuilderTypes.HtmlTag] with tags.FormTags[BuilderTypes.HtmlTag]
with tags.SectionTags[BuilderTypes.HtmlTag] with tags.TableTags[BuilderTypes.HtmlTag] with TagBuilder
with TagHelpers with EmbedTagDeprecations[BuilderTypes.HtmlTag]

trait TagsExtra
extends tags.DocumentTags[BuilderTypes.HtmlTag] with tags.MiscTags[BuilderTypes.HtmlTag] with TagBuilder
with DocumentTagDeprecations[BuilderTypes.HtmlTag]
trait TagsExtra extends tags.DocumentTags[BuilderTypes.HtmlTag] with tags.MiscTags[BuilderTypes.HtmlTag] with TagBuilder

trait SvgTags extends tags.SvgTags[BuilderTypes.SvgTag] with TagBuilder

// all Attributes
trait Attributes
extends HtmlAttrs with Events with AttributeHelpers with OutwatchAttributes with HtmlAttributeDeprecations
trait Attributes extends HtmlAttrs with Events with AdditionalAttributes with OutwatchAttributes

// Html Attrs
trait HtmlAttrs
Expand Down Expand Up @@ -109,9 +105,7 @@ trait HtmlAttrs
}

// Svg Attrs
trait SvgAttrs
extends attrs.SvgAttrs[BuilderTypes.Attribute] with builders.SvgAttrBuilder[BuilderTypes.Attribute]
with SvgAttributeDeprecations {
trait SvgAttrs extends attrs.SvgAttrs[BuilderTypes.Attribute] with builders.SvgAttrBuilder[BuilderTypes.Attribute] {

// According to snabbdom documentation, the namespace can be ignore as it is handled automatically.
override protected final def svgAttr[V](
Expand Down
Loading

0 comments on commit 1686dba

Please sign in to comment.