Skip to content

Commit 9f8092a

Browse files
committed
[Core] Add ParameterProvider interface.
1 parent 6381201 commit 9f8092a

File tree

4 files changed

+22
-9
lines changed

4 files changed

+22
-9
lines changed

formula/src/main/java/com/instacart/formula/ActionBuilder.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ abstract class ActionBuilder<out Input, State>(
2020
/**
2121
* Current input associated with the Formula evaluation.
2222
*/
23-
val input: Input,
23+
override val input: Input,
2424
/**
2525
* Current state associated with the Formula evaluation.
2626
*/
27-
val state: State,
28-
) {
27+
override val state: State,
28+
) : ParameterProvider<Input, State> {
2929

3030
/**
3131
* Adds an [Action] as part of this [Evaluation]. [Action] will be initialized
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.instacart.formula
2+
3+
interface ParameterProvider<out Input, State> {
4+
5+
/**
6+
* Current formula input.
7+
*/
8+
val input: Input
9+
/**
10+
* Current formula state.
11+
*/
12+
val state: State
13+
}

formula/src/main/java/com/instacart/formula/Snapshot.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ package com.instacart.formula
66
* is a state change within the Formula hierarchy, a new snapshot will be generated and
77
* [Formula.evaluate] will be called again.
88
*/
9-
interface Snapshot<out Input, State> {
9+
interface Snapshot<out Input, State> : ParameterProvider<Input, State> {
1010

1111
/**
1212
* The current Formula input value passed by the parent.
1313
*/
14-
val input: Input
14+
override val input: Input
1515

1616
/**
1717
* The current Formula state value.
1818
*/
19-
val state: State
19+
override val state: State
2020

2121
/**
2222
* Context is a short-lived object associated with the current evaluation. It should not be

formula/src/main/java/com/instacart/formula/TransitionContext.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import com.instacart.formula.internal.toResult
99
* Transition context provides the current [input], the current [state] and utilities to help
1010
* create [Transition.Result] within [Transition.toResult].
1111
*/
12-
interface TransitionContext<out Input, State> {
12+
interface TransitionContext<out Input, State> : ParameterProvider<Input, State> {
1313

1414
val effectDelegate: EffectDelegate
15-
val input: Input
16-
val state: State
15+
override val input: Input
16+
override val state: State
1717

1818
/**
1919
* Returns a result that indicates to do nothing as part of this event.

0 commit comments

Comments
 (0)