File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed
core/src/main/scala/torstenrudolf/scalajs/react/formbinder Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -16,12 +16,12 @@ flexibility of the form design.
16
16
Currently it is available as a sonatype snapshot, add this to your build.sbt:
17
17
18
18
```
19
- libraryDependencies += "com.github.torstenrudolf.scalajs-react-form-binder" %%% "core" % "0.0.15 -SNAPSHOT"
19
+ libraryDependencies += "com.github.torstenrudolf.scalajs-react-form-binder" %%% "core" % "0.0.16 -SNAPSHOT"
20
20
```
21
21
22
22
If you want to use the materialui form-field descriptors, you'll need this as well:
23
23
```
24
- libraryDependencies += "com.github.torstenrudolf.scalajs-react-form-binder" %%% "extras" % "0.0.15 -SNAPSHOT"
24
+ libraryDependencies += "com.github.torstenrudolf.scalajs-react-form-binder" %%% "extras" % "0.0.16 -SNAPSHOT"
25
25
```
26
26
27
27
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ def commonSettings: Project => Project =
3
3
_.enablePlugins(ScalaJSPlugin )
4
4
.settings(
5
5
organization := " com.github.torstenrudolf.scalajs-react-form-binder" ,
6
- version := " 0.0.15 -SNAPSHOT" ,
6
+ version := " 0.0.16 -SNAPSHOT" ,
7
7
homepage := Some (url(" https://github.com/torstenrudolf/scalajs-react-form-binder" )),
8
8
licenses += (" MIT" , url(" https://opensource.org/licenses/MIT" )),
9
9
scalaVersion := " 2.11.8" ,
Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ trait Form[DataModel] {
29
29
30
30
def resetAllFields : Callback
31
31
32
+ def subscribeToUpdates (cb : Callback ): Unit
33
+
32
34
}
33
35
34
36
Original file line number Diff line number Diff line change @@ -443,6 +443,8 @@ trait FormAPI[T] extends Form[T] {
443
443
444
444
private var _validatedFormData : Option [T ] = None
445
445
private var _formGlobalValidationResult : Option [ValidationResult ] = None
446
+ private val _formOnChangeSubscribers : scala.collection.mutable.ListBuffer [Callback ] =
447
+ scala.collection.mutable.ListBuffer .empty[Callback ]
446
448
447
449
private def formGlobalValidationResult : ValidationResult = _formGlobalValidationResult match {
448
450
case Some (vr) => vr
@@ -491,7 +493,9 @@ trait FormAPI[T] extends Form[T] {
491
493
492
494
def onChangeCB : Callback = {
493
495
validate(showUninitializedError = false )
496
+
494
497
formLayout.onChange(validatedData = _validatedFormData) >>
498
+ _formOnChangeSubscribers.foldLeft(Callback .empty)(_ >> _) >>
495
499
forceGlobalValidationMessageUpdate.getOrElse(Callback .empty)
496
500
}
497
501
@@ -551,6 +555,8 @@ trait FormAPI[T] extends Form[T] {
551
555
case Failure (e) => throw FormUninitialized
552
556
}
553
557
558
+ override def subscribeToUpdates (cb : Callback ): Unit = _formOnChangeSubscribers.append(cb)
559
+
554
560
private var forceGlobalValidationMessageUpdate : Option [Callback ] = None
555
561
556
562
override def globalValidationMessage : ReactNode = {
You can’t perform that action at this time.
0 commit comments