<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 <<a href="mailto:supittma@redhat.com">supittma@redhat.com</a>> 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<T>` interface. These would be:<br><br>```java<br>/**<br> * If store is open, it can be read or written to.<br> */<br>boolean isOpen();<br><br>/**<br> * Opens store in current thread (blocking).<br> */<br>Store<T> open();<br><br>/**<br> * Opens store in background thread and then callback#onSuccess is called.<br> */<br>void open(Callback<Store<T>> 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"> </span><br>review.<br><blockquote type="cite"><br><blockquote type="cite">From my point of view, this makes sense to be in the `Store<T>` 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<T>`.<br></blockquote><br>```java<br>/**<br> * Reads all the data from the underlying storage system asynchronously.<br> */<br>void readAll(Callback<Collection<T>> callback);<br><br>/**<br> * Reads a specific object/record from the underlying storage system asynchronously.<br> */<br>void read(Serializable id, Callback<T> callback);<br><br>/**<br> * Search for objects/records from the underlying storage system asynchronously.<br> */<br>void readWithFilter(ReadFilter filter, Callback<List<T>> callback);<br><br>/**<br> * Saves the given object in the underlying storage system asynchronously.<br> */<br>void save(T item, Callback<Void> callback);<br><br>/**<br> * Resets the entire storage system asynchronously.<br> */<br>void reset(Callback<Void> callback);<br><br>/**<br> * Removes a specific object/record from the underlying storage system asynchronously.<br> */<br>void remove(Serializable id, Callback<Void> callback);<br><br>/**<br> * Checks if the storage system contains no stored elements asynchronously.<br> */<br>void isEmpty(Callback<Boolean> 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"> </span><br>read and friends. That way a developer doesn't accidentally open a<span class="Apple-converted-space"> </span><br>database he meant to be closed. I don't have that strong of a feeling on<span class="Apple-converted-space"> </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"> </span><br>prefer for the Store to be synchronous and Pipes to be asynchronous. We<span class="Apple-converted-space"> </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<Store<T>> 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>