feathers-reactive icon indicating copy to clipboard operation
feathers-reactive copied to clipboard

"strategy=always" does not trigger brand new request

Open elixiao opened this issue 7 years ago • 12 comments

How could I trigger brand new request every time I use service.find? strategy=always does not work, and listStrategy=always does not work either. There is still no http request in my browser console. So what's the difference between strategy and listStrategy? (I see them both in README.md). Which one fulfill my purpose? Following is my code:

// feathers.service.ts
this.app = feathers()
  .configure(reactive({
    idField: '_id',
    listStrategy: 'always',
    strategy: 'always'
  }))
  .configure(rest(HOST).angularHttpClient(httpClient, {HttpHeaders}))
  .configure(hooks())
  .configure(authentication({path: '/login', storage: window.localStorage}))   
// role.component.ts
getRoles() {
  const Role = this.feathersService.app.service('roles')
  const log = console.log
  Role
    .watch({listStrategy: 'always', strategy: 'always'})
    .find()
    .subscribe(log,log)
}

elixiao avatar Jan 30 '18 08:01 elixiao

Does your problem persist with the new version?

j2L4e avatar Feb 14 '18 07:02 j2L4e

upgrading to latest version shows me the following error:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'mixins' of undefined
TypeError: Cannot read property 'mixins' of undefined

elixiao avatar Feb 23 '18 10:02 elixiao

Not working for me either, causing major issues, any ideas on a fix

dottodot avatar Jul 15 '18 15:07 dottodot

The reason this is an issue is it you have a list view that has different populated fields to the edit view it seems to break the population if you go back to edit the same item. The only way they stay in sync is by populating the find and get requests with the same fields, but I don't want to do that.

dottodot avatar Jul 24 '18 12:07 dottodot

Does anyone have a work around for this issue. It's causing me some issues and I'd prefer not to have find an alternative.

dottodot avatar Aug 06 '18 12:08 dottodot

Seems like a caching issue to me.

@daffl I think baking caching right into the plugin wasn't exactly the best of ideas we should refactor caching to make it configurable like sorters and matchers are.

j2L4e avatar Aug 06 '18 13:08 j2L4e

Maybe caching should just be disable for always. As the docs state

always - Re-runs the original query to always get fresh data from the server on any matching real-time event

so in this case caching doesn't make sense as you want the fresh data from the server.

dottodot avatar Aug 06 '18 14:08 dottodot

it DOES get new data from the server when an event occured. It just doesn't request new data when you subscribe twice with the same query.

Making caching configurable shouldn't be too much work. PRs welcome ;)

j2L4e avatar Aug 06 '18 15:08 j2L4e

Would it be as simple as adding say cache: true to the options then checking for that in list.js at this point.

   if (cachedObservable) {
      return cachedObservable;
    }

dottodot avatar Aug 06 '18 16:08 dottodot

To disable caching on your local version change return cacheObservable(this._cache, 'find', params ,pipeStream); to return pipeStream;

I think we'd need to figure out the API for a user provided cache, most likely some kind of object with cache, get and invalidate methods

j2L4e avatar Aug 06 '18 16:08 j2L4e

upgrading to latest version shows me the following error:

ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'mixins' of undefined
TypeError: Cannot read property 'mixins' of undefined

Does anyone have a work around for this?

ArdynVex avatar Sep 19 '18 13:09 ArdynVex

Please create a new issue with an example to reproduce.

daffl avatar Sep 19 '18 14:09 daffl