UNPKG

lacona-command-osx

Version:

Lacona Extensions for OSX, tied into the global-context hosted API

33 lines (26 loc) 690 B
import _ from 'lodash' import {Source} from 'lacona-phrase' export default class SpotlightFetch extends Source { onCreate () { this.replaceData([]) this.currentQueryId = null } onDeactivate () { this.replaceData([]) } onDestroy () { global.cancelQuery(this.currentQueryId) } fetch (query) { if (this.currentQueryId != null) { global.cancelQuery(this.currentQueryId) } this.currentQueryId = global.spotlight(query, this.props.attributes, this.props.limit, this.props.liveUpdate, this.replaceData.bind(this)) } } SpotlightFetch.defaultProps = { liveUpdate: false, attributes: [], limit: 100 } SpotlightFetch.preventSharing = true