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

feat: update angular version, code DX, examples and tests #1

Merged
merged 13 commits into from
Nov 13, 2023
Merged

feat: update angular version, code DX, examples and tests #1

merged 13 commits into from
Nov 13, 2023

Conversation

eneajaho
Copy link

No description provided.

@eneajaho eneajaho changed the base branch from main to feature/angular-query November 10, 2023 23:40
@eneajaho eneajaho mentioned this pull request Nov 10, 2023
13 tasks
@eneajaho eneajaho changed the title feat: update angular, code DX, examples and tests feat: update angular version, code DX, examples and tests Nov 10, 2023
docs/angular/overview.md Outdated Show resolved Hide resolved
@arnoud-dv
Copy link

Awesome PR, thanks! Will look at it more tomorrow. Will be fun also to think of how to architecture Angular apps around TanStack Query, e.g. what role would services have in this?

One way is to define a default queryFn via the QueryClient options and pass enough information via the query key so the query fn can fetch data. Then you'd need some kind of key factory (or multiple) which could be in services and only essential logic would remain in components. Disadvantage is that having correct types is quite hard then but other than that I'm fond of this idea.

There are probably other good solutions too, interested in any ideas you might have.

@arnoud-dv
Copy link

arnoud-dv commented Nov 11, 2023

Starting the simple example, I am getting the error again I had before. Don't know what causes it but copy / pasting the function from ngxtension but leaving out a few lines fixes it for me.
image

@eneajaho
Copy link
Author

Starting the simple example, I am getting the error again I had before. Don't know what causes it but copy / pasting the function from ngxtension but leaving out a few lines fixes it for me.

image

I will debug it a bit later today. And maybe we can also have a sync to try to write some more docs on how to use it.

@arnoud-dv
Copy link

And maybe we can also have a sync to try to write some more docs on how to use it.

I am currently working on adjusting the React Query documentation under the 'Guides & concepts' menu by adding Angular examples and making changes here and there.

After that I think I'll work on adding more examples, will be a lot of work so feel free to pick any of these. What I am currently thinking of adding:

  • Auto refetching
  • Pagination
  • Infinite scroll
  • Combining with routing
  • One example on how to integrate in an application using NgModule. All other examples should be standalone and without modules.
  • SSR (did not test this yet and it probably requires some code changes to the adapter)
  • Various reactivity examples, by passing signals into the injectQuery function
  • Some examples about combining it with RxJS streams, which I think is a really powerful combination
  • Micro frontends with multiple QueryClients
  • The queryOptions function that was recently added to TanStack Query
  • Query key factory
  • Maybe ways to use services to make queries available to the application.

…fields instead of query itself being a signal and improved types
@eneajaho
Copy link
Author

The last commit introduces a proxy object (inspired by rx-angular rxState ) implementation.

Basically, it converts the query signal to a query object that has signals fields (uses computed underneath)

query = injectQuery();

// Before
query().data
query().isPending

// After
query.data()
query.isPending()

Also, takes care of function calls, to not convert them into signals too 😅

@tomalaforge
Copy link

Awesome work @eneajaho, really like your last commit with the proxy.

@eneajaho
Copy link
Author

Awesome work @eneajaho, really like your last commit with the proxy.

You can see where I got the inspiration from 😄

rxState and rxActions do the same trick under the hood

https://github.com/rx-angular/rx-angular/blob/main/libs/state/actions/src/lib/proxy.ts
https://github.com/rx-angular/rx-angular/blob/main/libs/state/src/lib/signal-state-proxy.ts

@arnoud-dv arnoud-dv merged commit e13d286 into inshared:feature/angular-query Nov 13, 2023
arnoud-dv pushed a commit that referenced this pull request Nov 19, 2023
fix(angular-query): improve development workflow
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

Successfully merging this pull request may close these issues.

4 participants