Skip to content

Instantly share code, notes, and snippets.

@PatrickJS
Last active May 17, 2024 03:40
Show Gist options
  • Save PatrickJS/e26269f706b145b11b062e0f5b653e37 to your computer and use it in GitHub Desktop.
Save PatrickJS/e26269f706b145b11b062e0f5b653e37 to your computer and use it in GitHub Desktop.
whats better server$ api?
const getData = server$((myArg) => {
console.log(myArg)
});
getData(new ServerConfig({
method: 'get'
}), myArg)
getData(serverConfig({
method: 'get'
}), myArg)
const getData = server$({
method: 'get'
}, (myArg) => {
console.log(myArg)
})
getData(myArg)
const getData2 = server$((myArg) => {
console.log(myArg)
})
getData2(myArg)
const getData = server$((myArg) => {
console.log(myArg)
}, {
method: 'get'
})
getData(myArg)
@nmn
Copy link

nmn commented May 9, 2024

This would be even better:

const getData = server$((myArg) => {
  console.log(myArg)
})
  .method(‘get’);

getData(myArg)

@PatrickJS
Copy link
Author

ha thats very JavaScript

@PatrickJS
Copy link
Author

I don't want to recreate all the fetch options 😩 also typing that would be insane

@wmertens
Copy link

3 configs:

  • app level: via qwikcity provider in root
  • definition level: via object given to server
  • call level: via specially tagged first parameter when calling. We already do that for AbortSignal.

I'd prefer having the object first for the definition level, it's easier to read. I don't like chaining.

@PatrickJS
Copy link
Author

yeah I can update this in another pr to have 3 levels of configs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment