2015-10-03 01:57:40 +08:00
---
layout: docs
title: DraftStore
2015-10-04 03:39:12 +08:00
edit_url: "https://github.com/nylas/N1/blob/master/src/flux/stores/draft-store.coffee"
2015-10-03 01:57:40 +08:00
---
2015-10-02 03:34:16 +08:00
2015-10-03 01:57:40 +08:00
< h2 > Summary< / h2 >
2015-10-02 03:34:16 +08:00
2015-10-03 01:57:40 +08:00
< div class = "markdown-from-sourecode" >
< p > < p > DraftStore responds to Actions that interact with Drafts and exposes
2015-10-02 03:34:16 +08:00
public getter methods to return Draft objects and sessions.< / p >
2015-10-03 01:57:40 +08:00
< p > It also creates and queues < a href = 'task.html' > Task< / a > objects to persist changes to the Nylas
2015-10-02 03:34:16 +08:00
API.< / p >
< p > Remember that a " Draft" is actually just a " Message" with < code > draft: true< / code > .< / p >
< / p >
2015-10-03 01:57:40 +08:00
< / div >
2015-10-02 03:34:16 +08:00
2015-10-03 01:57:40 +08:00
< ul >
< / ul >
2015-10-02 03:34:16 +08:00
2015-10-03 01:57:40 +08:00
< h3 > Instance Methods< / h3 >
2015-10-02 03:34:16 +08:00
2015-10-03 01:57:40 +08:00
< h4 id = sessionForClientId class = "function-name" >
sessionForClientId(< span class = "args" > < span class = "arg" > clientId< / span > < / span > ) < a href = "#sessionForClientId" class = "link" > < / a >
< / h4 >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< div class = "function-description markdown-from-sourecode" >
< p > < p > Fetch a < a href = 'draftstoreproxy.html' > DraftStoreProxy< / a > for displaying and/or editing the
draft with < code > clientId< / code > .< / p >
< p > Example:< / p >
< pre > < code class = "lang-coffee" > session = < span class = "hljs-type" > DraftStore< / span > .sessionForClientId(clientId)
session.prepare< span class = "hljs-literal" > ()< / span > .< span class = "hljs-keyword" > then< / span > ->
# session.draft< span class = "hljs-literal" > ()< / span > is now ready
< / code > < / pre >
< / p >
< / div >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< strong > Parameters< / strong >
< table class = "arguments" >
2015-10-02 03:34:16 +08:00
< tr >
2015-10-03 01:57:40 +08:00
< th > Argument< / th >
< th > Description< / th >
2015-10-02 03:34:16 +08:00
< / tr >
< tr >
2015-10-03 01:57:40 +08:00
< td style = "width:15%;" >
< em > clientId< / em >
< / td >
< td class = "markdown-from-sourecode" >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< p > The < a href = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/string' > String< / a > clientId of the draft.< / p >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< / td >
2015-10-02 03:34:16 +08:00
< / tr >
2015-10-03 01:57:40 +08:00
< / table >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< strong > Returns< / strong >
< table class = "arguments" >
< tr >
< th > Return Values< / th >
< / tr >
< tr > < td class = "markdown-from-sourecode" > < p > Returns a < a href = 'https://github.com/petkaantonov/bluebird/blob/master/API.md' > Promise< / a > that resolves to an < a href = 'draftstoreproxy.html' > DraftStoreProxy< / a > for the
draft once it has been prepared:< / p >
< / td > < / tr >
< / table >
< h4 id = isSendingDraft class = "function-name" >
isSendingDraft(< span class = "args" > < / span > ) < a href = "#isSendingDraft" class = "link" > < / a >
< / h4 >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< div class = "function-description markdown-from-sourecode" >
< p > < p > Look up the sending state of the given draftClientId.
In popout windows the existance of the window is the sending state. < / p >
< / p >
< / div >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< h4 id = extensions class = "function-name" >
extensions(< span class = "args" > < / span > ) < a href = "#extensions" class = "link" > < / a >
< / h4 >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< div class = "function-description markdown-from-sourecode" >
< p > < / p >
< / div >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< strong > Returns< / strong >
< table class = "arguments" >
< tr >
< th > Return Values< / th >
< / tr >
< tr > < td class = "markdown-from-sourecode" > < p > Returns the extensions registered with the DraftStore.< / p >
< / td > < / tr >
< / table >
< h4 id = registerExtension class = "function-name" >
registerExtension(< span class = "args" > < span class = "arg" > ext< / span > < / span > ) < a href = "#registerExtension" class = "link" > < / a >
< / h4 >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< div class = "function-description markdown-from-sourecode" >
< p > < p > Registers a new extension with the DraftStore. DraftStore extensions
make it possible to extend the editor experience, modify draft contents,
display warnings before draft are sent, and more.< / p >
< / p >
< / div >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< strong > Parameters< / strong >
< table class = "arguments" >
< tr >
< th > Argument< / th >
< th > Description< / th >
< / tr >
< tr >
< td style = "width:15%;" >
< em > ext< / em >
< / td >
< td class = "markdown-from-sourecode" >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< p > A < a href = 'draftstoreextension.html' > DraftStoreExtension< / a > instance.< / p >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< / td >
< / tr >
< / table >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< h4 id = unregisterExtension class = "function-name" >
unregisterExtension(< span class = "args" > < span class = "arg" > ext< / span > < / span > ) < a href = "#unregisterExtension" class = "link" > < / a >
< / h4 >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< div class = "function-description markdown-from-sourecode" >
< p > < p > Unregisters the extension provided from the DraftStore.< / p >
< / p >
< / div >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< strong > Parameters< / strong >
< table class = "arguments" >
< tr >
< th > Argument< / th >
< th > Description< / th >
< / tr >
< tr >
< td style = "width:15%;" >
< em > ext< / em >
< / td >
< td class = "markdown-from-sourecode" >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< p > A < a href = 'draftstoreextension.html' > DraftStoreExtension< / a > instance.< / p >
2015-10-04 03:39:12 +08:00
2015-10-03 01:57:40 +08:00
< / td >
< / tr >
< / table >