<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Courier New";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">I'd pick "whenever" or "onCondition".<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">"updateWhen" sounds like an update, which I think it is not.  "when" seems too vague.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">Disclaimer: English is not my native language.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New"">-andy<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="margin-bottom:12.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">openjfx-dev <openjfx-dev-retn@openjdk.org> on behalf of Kevin Rushforth <kevin.rushforth@oracle.com><br>
<b>Date: </b>Monday, 2022/11/14 at 09:40<br>
<b>To: </b>openjfx-dev@openjdk.org <openjfx-dev@openjdk.org><br>
<b>Subject: </b>Re: Discussion: Naming API method<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt">I also think this will be a useful feature to get into JavaFX.<br>
<br>
As for the name of the method, the only one of them I don't like is <br>
"conditionOn". That name doesn't suggest (to me anyway) what its purpose <br>
is. I think any of the ones with "when" in the name would work. I have a <br>
slight preference for "updateWhen", but could be talked into one of the <br>
others.<br>
<br>
-- Kevin<br>
<br>
<br>
On 11/14/2022 6:52 AM, John Hendrikx wrote:<br>
> Hi,<br>
><br>
> I'm working on <a href="https://github.com/openjdk/jfx/pull/830">https://github.com/openjdk/jfx/pull/830</a> where I asked
<br>
> for some opinions on the naming of a new method I'd like to introduce <br>
> in ObservableValue.<br>
><br>
> I wrote a (perhaps too large) comment about the possible names and <br>
> rationales: <br>
> <a href="https://github.com/openjdk/jfx/pull/830#issuecomment-1304846220">https://github.com/openjdk/jfx/pull/830#issuecomment-1304846220</a><br>
><br>
> I'd like to ask what others think what would be a good name for this <br>
> new method (Observable#when in the PR) in order to move the PR <br>
> forward, as I think it offers a very compelling feature to JavaFX <br>
> (moving from weak reference to deterministic behavior when it comes to <br>
> listener management).  My opinion has always been that using weak <br>
> listeners for listener management is a crutch that relies far too much <br>
> on the internal workings of the JVM and Garbage Collector which offer <br>
> no guarantees as to the timely clean up of these references and the <br>
> listeners related to them.<br>
><br>
> Leading contenders are (but not limited to these, if you have a better <br>
> name):<br>
><br>
> 1) conditionOn<br>
><br>
> 2) updateWhen<br>
><br>
> 3) when<br>
><br>
> 4) whenever<br>
><br>
> Usage in code is nearly always going to be something like these <br>
> constructs:<br>
><br>
>       // keeps text property in sync with longLivedProperty when label <br>
> is shown:<br>
> label.textProperty().bind(longLivedProperty.**when**(label::isShownProperty)); <br>
><br>
><br>
>       // keeps text property in sync with longLivedProperty when <br>
> container is shown:<br>
> label.textProperty().bind(longLivedProperty.**when**(container::isShownProperty));
<br>
><br>
><br>
> It can also be used to make a listener only actively listen when a <br>
> condition is met (the listener is added/removed immediately when the <br>
> condition changes, facilitating GC):<br>
><br>
>       // listen to changes of longLivedProperty when container is shown:<br>
>       longLivedProperty.when(container::isShownProperty)<br>
>             .addListener((obs, old, current) -> { ... change listener <br>
> ... });<br>
><br>
> Or it can be used to disable updates temporarily (or permanently):<br>
><br>
>         BooleanProperty allowUpdates = new SimpleBooleanProperty(true)<br>
><br>
>         // keeps text property in sync when updates are allowed:<br>
>         name.textProperty().bind(model.title.when(allowUpdates));<br>
> detail.textProperty().bind(model.subtitle.when(allowUpdates));<br>
> asyncImageProperty.imageHandleProperty().bind(model.imageHandle.when(allowUpdates));
<br>
><br>
><br>
> This last example can be useful in Skin#dispose, but has uses outside <br>
> of skins as well, for example when you want to prevent updates until <br>
> things have settled down.<br>
><br>
> Thanks for reading!<br>
><br>
> --John<br>
><br>
><o:p></o:p></span></p>
</div>
</div>
</body>
</html>