Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x: Fix wrong example for Config.onChange (#7716) #8592

Merged
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
4 changes: 2 additions & 2 deletions config/config/src/main/java/io/helidon/config/Config.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2023 Oracle and/or its affiliates.
* Copyright (c) 2017, 2024 Oracle and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -842,7 +842,7 @@ default ConfigValue<Config> asNode() {
/**
* Register a {@link Consumer} that is invoked each time a change occurs on whole Config or on a particular Config node.
* <p>
* A user can subscribe on root Config node and than will be notified on any change of Configuration.
* A user can subscribe on root Config node and then will be notified on any change of Configuration.
* You can also subscribe on any sub-node, i.e. you will receive notification events just about sub-configuration.
* No matter how much the sub-configuration has changed you will receive just one notification event that is associated
* with a node you are subscribed on.
Expand Down
11 changes: 4 additions & 7 deletions docs/se/config/mutability-support.adoc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
///////////////////////////////////////////////////////////////////////////////

Copyright (c) 2018, 2023 Oracle and/or its affiliates.
Copyright (c) 2018, 2024 Oracle and/or its affiliates.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -151,19 +151,16 @@ method on the node of interest.
.Subscribe on `greeting` property changes via `onChange` method
----
config.get("greeting") // <1>
.onChange((changedNode) -> { // <2>
.onChange(changedNode -> { // <2>
System.out.println("Node " + changedNode.key() + " has changed!");
return true; // <3>
});
----

<1> Navigate to the `Config` node on which you want to register.
<2> Invoke the `onChange` method, passing a function (`Function<Config, Boolean>`).
The config system invokes that function each time the subtree rooted at the
<2> Invoke the `onChange` method, passing a consumer (`Consumer<Config>`).
The config system invokes that consumer each time the subtree rooted at the
`greeting` node changes. The `changedNode` is a new instance of `Config`
representing the updated subtree rooted at `greeting`.
<3> The function should return `true` to continue being run on subsequent changes, `false`
to stop.

== Accessing Always-current Values
Some applications do not need to respond to change as they happen. Instead, it's
Expand Down
Loading