Mailspring/docs/DatabaseView.html
2015-10-03 12:39:26 -07:00

66 lines
2.2 KiB
HTML

---
layout: docs
title: DatabaseView
edit_url: "https://github.com/nylas/N1/blob/master/src/flux/stores/database-view.coffee"
---
<h2>Summary</h2>
<div class="markdown-from-sourecode">
<p><p>DatabaseView abstracts away the process of paginating a query
and loading ranges of data. It&#39;s very smart about deciding when
results need to be refreshed. There are a few core concepts that
make it flexible:</p>
<p>metadataProvider: For each item loaded, you can provide a promise
that resolves with additional data for that item. The DatabaseView
will not consider the page of data &quot;loaded&quot; until all the metadata
promises have resolved. (Used for message metadata on threads)</p>
<p>retainedRange: The retained range ({start, end}) represents the
objects currently being displayed. React components displaying the
view can alter the retained range as the user scrolls.</p>
<p>Note: Do not make the retainedRange larger than you need. The
DatabaseView may internally keep a larger set of items loaded
for performance.</p>
</p>
</div>
<ul>
</ul>
<h3>Instance Methods</h3>
<h4 id=invalidate class="function-name">
invalidate(<span class="args"><span class="arg">options</span></span>) <a href="#invalidate" class="link"></a>
</h4>
<div class="function-description markdown-from-sourecode">
<p><p>Call this method when the DatabaseStore triggers and will impact the
data maintained by this DatabaseView. In the future, the DatabaseView will
probably observe the DatabaseView directly.</p>
<p>TODO: In order for the DatabaseView to monitor the DatabaseStore directly,
it needs to have some way of detatching it&#39;s listener when it&#39;s no longer needed!
Need a destructor...</p>
</p>
</div>
<strong>Parameters</strong>
<table class="arguments">
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td style="width:15%;">
<em>options</em>
</td>
<td class="markdown-from-sourecode">
<p>an Object with the following optional keys which can be used to optimize the behavior of the DatabaseView:</p>
</td>
</tr>
</table>