<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 08 Jan 2014, at 15:30, Summers Pittman &lt;<a 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’ve been recently going through the DataManager API in aerogear-android. In this email, I’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’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’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’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’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’s right, it’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 “void open(Callback&lt;Store&lt;T&gt;&gt; callback);” 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’t it?</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>—<br>Tadeas Kriz<br><a href="mailto:tkriz@redhat.com">tkriz@redhat.com</a><br><br><br>_______________________________________________<br>aerogear-dev mailing list<br><a href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br><a 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 href="mailto:aerogear-dev@lists.jboss.org">aerogear-dev@lists.jboss.org</a><br><a href="https://lists.jboss.org/mailman/listinfo/aerogear-dev">https://lists.jboss.org/mailman/listinfo/aerogear-dev</a></div></blockquote></div><br></body></html>