mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-19 23:17:16 +03:00
Make StorageFolder.store async
Signed-off-by: Nathan Sobo <nathan@github.com>
This commit is contained in:
parent
7c8f73b2d8
commit
e2ad4e6a8b
@ -909,7 +909,7 @@ class AtomApplication extends EventEmitter {
|
||||
}
|
||||
}
|
||||
|
||||
saveState (allowEmpty = false) {
|
||||
async saveState (allowEmpty = false) {
|
||||
if (this.quitting) return
|
||||
|
||||
const states = []
|
||||
@ -919,7 +919,7 @@ class AtomApplication extends EventEmitter {
|
||||
states.reverse()
|
||||
|
||||
if (states.length > 0 || allowEmpty) {
|
||||
this.storageFolder.storeSync('application.json', states)
|
||||
await this.storageFolder.store('application.json', states)
|
||||
this.emit('application:did-save-state')
|
||||
}
|
||||
}
|
||||
|
@ -19,10 +19,13 @@ class StorageFolder {
|
||||
})
|
||||
}
|
||||
|
||||
storeSync (name, object) {
|
||||
if (!this.path) return
|
||||
|
||||
fs.writeFileSync(this.pathForKey(name), JSON.stringify(object), 'utf8')
|
||||
store (name, object) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!this.path) return resolve()
|
||||
fs.writeFile(this.pathForKey(name), JSON.stringify(object), 'utf8', error =>
|
||||
error ? reject(error) : resolve()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
load (name) {
|
||||
|
Loading…
Reference in New Issue
Block a user