Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,32 @@ public interface ComponentBuilder<S extends ComponentBuilder<S, C>, C extends IF
*
* @param states The state to watch.
* @return This component builder.
* @deprecated Use {@link #updateOnStateChange(State)} instead.
*/
@Deprecated
@ApiStatus.ScheduledForRemoval(inVersion = "3.2.0")
S watch(State<?>... states);

/**
* Listens for value updates in the specified state.
* <p>
* Everytime the value of the given state updates, this component will be updated as well.
*
* @param state The state to listen changes to.
* @return This component builder.
*/
S updateOnStateChange(@NotNull State<?> state);

/**
* Listens for value updates in any of the specified states.
* <p>
* Everytime the value ANY of the given state updates, this component will be updated as well.
*
* @param states The state to listen changes to.
* @return This component builder.
*/
S updateOnStateChange(State<?>... states);

/**
* Returns a copy of this component builder.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ public S watch(State<?>... states) {
return (S) this;
}

@Override
public S updateOnStateChange(@NotNull State<?> state) {
if (watchingStates == null) watchingStates = new LinkedHashSet<>();
watchingStates.add(state);
return (S) this;
}

@Override
public S updateOnStateChange(State<?>... states) {
if (watchingStates == null) watchingStates = new LinkedHashSet<>();
watchingStates.addAll(Arrays.asList(states));
return (S) this;
}

@Override
public S withExternallyManaged(boolean isExternallyManaged) {
isManagedExternally = isExternallyManaged;
Expand Down