<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 01/08/2014 10:09 AM, Tadeas Kriz
      wrote:<br>
    </div>
    <blockquote
      cite="mid:CF16F3E3-F594-4A09-860E-63CC020E5DC4@redhat.com"
      type="cite">
      <meta http-equiv="Content-Type" content="text/html;
        charset=ISO-8859-1">
      <br>
      <div apple-content-edited="true">
        <div>&#8212;</div>
        <div>Tadeas Kriz</div>
        <div><a moz-do-not-send="true" href="mailto:tkriz@redhat.com">tkriz@redhat.com</a></div>
      </div>
      <br>
      <div>
        <div>On 08 Jan 2014, at 16:04, Summers Pittman &lt;<a
            moz-do-not-send="true" href="mailto:supittma@redhat.com">supittma@redhat.com</a>&gt;
          wrote:</div>
        <br class="Apple-interchange-newline">
        <blockquote type="cite">
          <meta content="text/html; charset=ISO-8859-1"
            http-equiv="Content-Type">
          <div bgcolor="#FFFFFF" text="#000000">
            <div class="moz-cite-prefix">On 01/08/2014 09:57 AM, Tadeas
              Kriz wrote:<br>
            </div>
            <blockquote
              cite="mid:B5C99187-AF43-4FB9-A62A-C0287B89738F@redhat.com"
              type="cite">
              <meta http-equiv="Content-Type" content="text/html;
                charset=ISO-8859-1">
              <br>
              <br>
              <div>
                <div>On 08 Jan 2014, at 15:53, Summers Pittman &lt;<a
                    moz-do-not-send="true"
                    href="mailto:supittma@redhat.com">supittma@redhat.com</a>&gt;

                  wrote:</div>
                <br class="Apple-interchange-newline">
                <blockquote type="cite">
                  <meta content="text/html; charset=ISO-8859-1"
                    http-equiv="Content-Type">
                  <div bgcolor="#FFFFFF" text="#000000">
                    <div class="moz-cite-prefix">On 01/08/2014 09:42 AM,
                      Tadeas Kriz wrote:<br>
                    </div>
                    <blockquote
                      cite="mid:0BE571A7-F030-4561-AEE8-FF87406E5877@redhat.com"
                      type="cite">
                      <meta http-equiv="Content-Type"
                        content="text/html; charset=ISO-8859-1">
                      <br>
                      <div>
                        <div>On 08 Jan 2014, at 15:30, Summers Pittman
                          &lt;<a moz-do-not-send="true"
                            href="mailto:supittma@redhat.com">supittma@redhat.com</a>&gt;


                          wrote:</div>
                        <br class="Apple-interchange-newline">
                        <blockquote type="cite">
                          <div style="font-size: 12px; font-style:
                            normal; font-variant: normal; font-weight:
                            normal; letter-spacing: normal; line-height:
                            normal; orphans: auto; text-align: start;
                            text-indent: 0px; text-transform: none;
                            white-space: normal; widows: auto;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;">On
                            01/08/2014 05:51 AM, Tadeas Kriz wrote:<br>
                            <blockquote type="cite">Hey everyone,<br>
                              <br>
                              I&#8217;ve been recently going through the
                              DataManager API in aerogear-android. In
                              this email, I&#8217;d like to suggest addiction
                              of two method (or possibly three) into the
                              `Store&lt;T&gt;` interface. These would
                              be:<br>
                              <br>
                              ```java<br>
                              /**<br>
                              &nbsp;* If store is open, it can be read or
                              written to.<br>
                              &nbsp;*/<br>
                              boolean isOpen();<br>
                              <br>
                              /**<br>
                              &nbsp;* Opens store in current thread
                              (blocking).<br>
                              &nbsp;*/<br>
                              Store&lt;T&gt; open();<br>
                              <br>
                              /**<br>
                              &nbsp;* Opens store in background thread and
                              then callback#onSuccess is called.<br>
                              &nbsp;*/<br>
                              void open(Callback&lt;Store&lt;T&gt;&gt;
                              callback);<br>
                              ```<br>
                            </blockquote>
                            I think those are fine. Feel free to JIRA it
                            up and Passos and I will<span
                              class="Apple-converted-space">&nbsp;</span><br>
                            review.<br>
                            <blockquote type="cite"><br>
                              <blockquote type="cite">From my point of
                                view, this makes sense to be in the
                                `Store&lt;T&gt;` so I can switch between
                                stores easily during development with no
                                need to change other code. Also, if
                                `read` or `write` operations are done
                                with closed store, there are two
                                possible workflows. First one is, that
                                I&#8217;d fail and throw an exception. Second
                                (and for me a preferred one) is, that
                                all those methods would internally check
                                if the store is open and if not, they&#8217;d
                                call the `open` method. This also leads
                                me to another API change for
                                `Store&lt;T&gt;`.<br>
                              </blockquote>
                              <br>
                              ```java<br>
                              /**<br>
                              &nbsp;* Reads all the data from the underlying
                              storage system asynchronously.<br>
                              &nbsp;*/<br>
                              void
                              readAll(Callback&lt;Collection&lt;T&gt;&gt;
                              callback);<br>
                              <br>
                              /**<br>
                              &nbsp;* Reads a specific object/record from the
                              underlying storage system asynchronously.<br>
                              &nbsp;*/<br>
                              void read(Serializable id,
                              Callback&lt;T&gt; callback);<br>
                              <br>
                              /**<br>
                              &nbsp;* Search for objects/records from the
                              underlying storage system asynchronously.<br>
                              &nbsp;*/<br>
                              void readWithFilter(ReadFilter filter,
                              Callback&lt;List&lt;T&gt;&gt; callback);<br>
                              <br>
                              /**<br>
                              &nbsp;* Saves the given object in the
                              underlying storage system asynchronously.<br>
                              &nbsp;*/<br>
                              void save(T item, Callback&lt;Void&gt;
                              callback);<br>
                              <br>
                              /**<br>
                              &nbsp;* Resets the entire storage system
                              asynchronously.<br>
                              &nbsp;*/<br>
                              void reset(Callback&lt;Void&gt; callback);<br>
                              <br>
                              /**<br>
                              &nbsp;* Removes a specific object/record from
                              the underlying storage system
                              asynchronously.<br>
                              &nbsp;*/<br>
                              void remove(Serializable id,
                              Callback&lt;Void&gt; callback);<br>
                              <br>
                              /**<br>
                              &nbsp;* Checks if the storage system contains
                              no stored elements asynchronously.<br>
                              &nbsp;*/<br>
                              void isEmpty(Callback&lt;Boolean&gt;
                              callback);<br>
                              ```<br>
                              <br>
                              That&#8217;s right, async methods for easy
                              access to the storage from background
                              thread, without the pain of writing it
                              myself (for example, it makes no sense if
                              I want to just call `store.save(..)` and
                              I&#8217;d have to write all the `AsyncTask`
                              boilerplate).<br>
                              <br>
                              So, what do you think?<br>
                            </blockquote>
                            <br>
                            I would rather throw an exception than open
                            a database when you call<span
                              class="Apple-converted-space">&nbsp;</span><br>
                            read and friends. That way a developer
                            doesn't accidentally open a<span
                              class="Apple-converted-space">&nbsp;</span><br>
                            database he meant to be closed. I don't have
                            that strong of a feeling on<span
                              class="Apple-converted-space">&nbsp;</span><br>
                            that point one way or another however.</div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>That&#8217;s right, it&#8217;s probably less error
                          prone in scenarios when you want the store
                          closed.</div>
                        <br>
                        <blockquote type="cite">
                          <div style="font-size: 12px; font-style:
                            normal; font-variant: normal; font-weight:
                            normal; letter-spacing: normal; line-height:
                            normal; orphans: auto; text-align: start;
                            text-indent: 0px; text-transform: none;
                            white-space: normal; widows: auto;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;"><br>
                            My stronger feeling is on adding callbacks
                            to the stores methods. I<span
                              class="Apple-converted-space">&nbsp;</span><br>
                            prefer for the Store to be synchronous and
                            Pipes to be asynchronous. We<span
                              class="Apple-converted-space">&nbsp;</span><br>
                            could add a StorePipe to our PypeTipes which
                            may solve some of the headache.<br>
                            <br>
                          </div>
                        </blockquote>
                        <div><br>
                        </div>
                        <div>Would &#8220;void
                          open(Callback&lt;Store&lt;T&gt;&gt;
                          callback);&#8221; make sense then? I mean, that
                          would add another inconsistency in the API, as
                          one method would be async and the rest would
                          be only synchronous, wouldn&#8217;t it?</div>
                      </div>
                    </blockquote>
                    True.&nbsp; The reason for the exception here was that
                    opening a SQL store or an encrypted store COULD take
                    significant amount of time. For in Memory data
                    stores this is instant of course.<br>
                  </div>
                </blockquote>
                <div>I understand, but that&#8217;s just an assumption. Let&#8217;s
                  say that there&#8217;s a storage, that&#8217;d take an instant to
                  load data from, but a lot of time to save data (like
                  XML file based store). What&#8217;s the main reason to not
                  have async &#8220;read&#8221;/&#8220;write&#8221; methods?</div>
              </div>
            </blockquote>
            <br>
            The best reason I can give is if your Store implementation
            will be that slow either a) Write a Pipe instead or b)
            Manage the latency yourself.<br>
            <br>
            In Android land you want code on your main thread to be fast
            or non blocking.&nbsp; If we are working off the main thread then
            having things be slow and blocking is less of an issue.&nbsp;
            Synchronous code is easier to debug (in Java) and easier to
            write (in Java) and faster (because we don't have to route
            through callback classes).<br>
            <br>
            Having either or, in my opinion, clouds what your usage
            target should be.<br>
            <br>
            Also this is the most though Stores have been given in a
            long time.&nbsp; Anything we come up with we will probably need
            to get the other platforms alerted to as well.<br>
            <br>
          </div>
        </blockquote>
        Well, sometimes you want to reload a ListView data and it&#8217;d make
        it so easy to just call &#8220;store.readAll(callback)&#8221; where in
        callback#onSuccess you&#8217;d remove progress indicator and notify
        the ListView about new data.</div>
      <div><br>
      </div>
      <div>BTW, I&#8217;ve been working on new DataManager API, which would be
        a lot more interesting for users (right now the need to cast it
        and also that it&#8217;s not easily extendable is a pain), so when I&#8217;m
        done with that, I&#8217;ll start another thread here on ML ;)<br>
      </div>
    </blockquote>
    <br>
    Awesome.&nbsp; I'm actually running into / ran into some of these issues
    with the DevNexus app I wrote.&nbsp; <br>
    <br>
    One of my original ideas for the Store implementations on Android
    would be they are very easy to integrated into ContentProviders
    which are async on their own.&nbsp; I never actually tested this idea so
    when you get your new Datamanage API up we can think about lots of
    things.<br>
    <br>
    <blockquote
      cite="mid:CF16F3E3-F594-4A09-860E-63CC020E5DC4@redhat.com"
      type="cite">
      <div>
        <blockquote type="cite">
          <div bgcolor="#FFFFFF" text="#000000"> <br>
            <blockquote
              cite="mid:B5C99187-AF43-4FB9-A62A-C0287B89738F@redhat.com"
              type="cite">
              <div>
                <blockquote type="cite">
                  <div bgcolor="#FFFFFF" text="#000000">
                    <blockquote
                      cite="mid:0BE571A7-F030-4561-AEE8-FF87406E5877@redhat.com"
                      type="cite">
                      <div><br>
                        <blockquote type="cite">
                          <div style="font-size: 12px; font-style:
                            normal; font-variant: normal; font-weight:
                            normal; letter-spacing: normal; line-height:
                            normal; orphans: auto; text-align: start;
                            text-indent: 0px; text-transform: none;
                            white-space: normal; widows: auto;
                            word-spacing: 0px;
                            -webkit-text-stroke-width: 0px;">Passos,
                            wdyt?<br>
                            <br>
                            <br>
                            <blockquote type="cite"><br>
                              PS: You can find the whole text with
                              highlighted syntax here:<br>
                              <br>
                              &#8212;<br>
                              Tadeas Kriz<br>
                              <a moz-do-not-send="true"
                                href="mailto:tkriz@redhat.com">tkriz@redhat.com</a><br>
                              <br>
                              <br>
_______________________________________________<br>
                              aerogear-dev mailing list<br>
                              <a moz-do-not-send="true"
                                href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
                              <a moz-do-not-send="true"
                                href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a><br>
                            </blockquote>
                            <br>
_______________________________________________<br>
                            aerogear-dev mailing list<br>
                            <a moz-do-not-send="true"
                              href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
                            <a moz-do-not-send="true"
                              href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></div>
                        </blockquote>
                      </div>
                      <br>
                      <br>
                      <fieldset class="mimeAttachmentHeader"></fieldset>
                      <br>
                      <pre wrap="">_______________________________________________
aerogear-dev mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></pre>
                    </blockquote>
                    <br>
                  </div>
                  _______________________________________________<br>
                  aerogear-dev mailing list<br>
                  <a moz-do-not-send="true"
                    href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
                  <a moz-do-not-send="true"
                    class="moz-txt-link-freetext"
                    href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></blockquote>
              </div>
              <br>
              <br>
              <fieldset class="mimeAttachmentHeader"></fieldset>
              <br>
              <pre wrap="">_______________________________________________
aerogear-dev mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></pre>
            </blockquote>
            <br>
          </div>
          _______________________________________________<br>
          aerogear-dev mailing list<br>
          <a moz-do-not-send="true"
            href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br>
          <a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></blockquote>
      </div>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
aerogear-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></pre>
    </blockquote>
    <br>
  </body>
</html>