   queryTransform: (collectionName, transformCallback) ->
     @_transforms[collectionName] = transformCallback
 
-  create: (config) -> new AntiSearchSourceClient(config)
-
-
+  create: (config) -> new AntiSearchSourceClient(config)
    if err then console.log('Error while searching', err)

  _stateChanged: -> @_stateFlag.set(!@_stateFlag.get())

  _updateQuery: ->
    @_stateChanged()

      @_searchSubscribtion = @_subscriptionContext.subscribe AntiSearchSource._publisherName, @_searchConfig, @_onSubscriptionReady

  setMongoQuery: (newMongoQuery) ->
    unless _.isEqual newMongoQuery, @_searchConfig.mongoQuery
      @_searchConfig.mongoQuery = newMongoQuery
      @_updateQuery()

# May be used for infinite scroll or something like that
  setLimit: (newLimit) ->
    unless @_searchConfig.limit == newLimit
      @_searchConfig.limit = newLimit
      @_updateQuery()

  incrementLimit: (step = 10) ->
    @_searchConfig.limit += step
    @_updateQuery()

# Reactive data source
  searchResult: (options = {}) ->
    @_stateFlag.get()
    if @_searchConfig.searchMode is 'local' or @_searchSubscribtion and @_searchSubscribtion.ready()
      query = AntiSearchSource._buildSearchQuery(@_searchConfig)
      _.extend options,
        limit: @_searchConfig.limit
        transform: @_createTransformFn(options.transform)

      return @_collection.find(query, options)

# Cancels subscription for search data
