<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    While rereading the proposed docs for the new method, the following
    stood out to me:<br>
    <br>
    "The returned ObservableValue only observes this value when
    condition holds true."<br>
    <br>
    So I agree that "updateWhen" isn't really accurate, but I don't care
    for "onCondition" either.<br>
    <br>
    I think "whenever" would be OK, but what about "observesWhen" (or
    maybe "observedWhen") as a name?<br>
    <br>
    -- Kevin<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 11/14/2022 9:47 AM, Andy Goryachev
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:DM5PR1001MB2172FD362C495C490D57A733E5059@DM5PR1001MB2172.namprd10.prod.outlook.com">
      
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@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;}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;}div.WordSection1
        {page:WordSection1;}</style>
      <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
              <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev-retn@openjdk.org"><openjfx-dev-retn@openjdk.org></a> on behalf of Kevin
              Rushforth <a class="moz-txt-link-rfc2396E" href="mailto:kevin.rushforth@oracle.com"><kevin.rushforth@oracle.com></a><br>
              <b>Date: </b>Monday, 2022/11/14 at 09:40<br>
              <b>To: </b><a class="moz-txt-link-abbreviated" href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a>
              <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.org"><openjfx-dev@openjdk.org></a><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" moz-do-not-send="true" class="moz-txt-link-freetext">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" moz-do-not-send="true" class="moz-txt-link-freetext">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>
    </blockquote>
    <br>
  </body>
</html>