Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap contact search into a more assistive endpoint #94

Closed
andrewxhill opened this issue May 6, 2019 · 1 comment
Closed

Wrap contact search into a more assistive endpoint #94

andrewxhill opened this issue May 6, 2019 · 1 comment
Assignees
Milestone

Comments

@andrewxhill
Copy link
Member

andrewxhill commented May 6, 2019

Currently,

  const queryId = await Textile.contacts.search(query, options)
  return eventChannel<SearchEvent>((emitter) => {
    const resultsSub = Textile.events.addContactQueryResultListener((receivedQueryId, contact) => {
      if (receivedQueryId === queryId) {
        emitter({ contact, type: 'contact' })
      }
    })
    const errorSub = Textile.events.addQueryErrorListener((receivedQueryId, error) => {
      if (receivedQueryId === queryId) {
        emitter({ error, type: 'error' })
        emitter(END)
      }
    })
    const doneSub = Textile.events.addQueryDoneListener((receivedQueryId) => {
      if (receivedQueryId === queryId) {
        emitter(END)
      }
    })
    return () => {
      Textile.contacts.cancelSearch()
      resultsSub.cancel()
      errorSub.cancel()
      doneSub.cancel()
    }
  })

Could we just have,

const queryId = await Textile.contacts.search(<query>, onResult, onDone, onError)

related:

#93

@andrewxhill andrewxhill added this to the Sprint 12 milestone May 13, 2019
@andrewxhill andrewxhill self-assigned this May 13, 2019
@andrewxhill
Copy link
Member Author

deprecated api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant