Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions formula/src/main/java/com/instacart/formula/ActionBuilder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ abstract class ActionBuilder<out Input, State>(
/**
* Current input associated with the Formula evaluation.
*/
val input: Input,
override val input: Input,
/**
* Current state associated with the Formula evaluation.
*/
val state: State,
) {
override val state: State,
) : ParameterProvider<Input, State> {

/**
* Adds an [Action] as part of this [Evaluation]. [Action] will be initialized
Expand Down
13 changes: 13 additions & 0 deletions formula/src/main/java/com/instacart/formula/ParameterProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.instacart.formula

interface ParameterProvider<out Input, State> {

/**
* Current formula input.
*/
val input: Input
/**
* Current formula state.
*/
val state: State
}
6 changes: 3 additions & 3 deletions formula/src/main/java/com/instacart/formula/Snapshot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ package com.instacart.formula
* is a state change within the Formula hierarchy, a new snapshot will be generated and
* [Formula.evaluate] will be called again.
*/
interface Snapshot<out Input, State> {
interface Snapshot<out Input, State> : ParameterProvider<Input, State> {

/**
* The current Formula input value passed by the parent.
*/
val input: Input
override val input: Input

/**
* The current Formula state value.
*/
val state: State
override val state: State

/**
* Context is a short-lived object associated with the current evaluation. It should not be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import com.instacart.formula.internal.toResult
* Transition context provides the current [input], the current [state] and utilities to help
* create [Transition.Result] within [Transition.toResult].
*/
interface TransitionContext<out Input, State> {
interface TransitionContext<out Input, State> : ParameterProvider<Input, State> {

val effectDelegate: EffectDelegate
val input: Input
val state: State
override val input: Input
override val state: State

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