Last active
May 17, 2024 03:40
-
-
Save PatrickJS/e26269f706b145b11b062e0f5b653e37 to your computer and use it in GitHub Desktop.
whats better server$ api?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getData = server$((myArg) => { | |
console.log(myArg) | |
}); | |
getData(new ServerConfig({ | |
method: 'get' | |
}), myArg) | |
getData(serverConfig({ | |
method: 'get' | |
}), myArg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getData = server$({ | |
method: 'get' | |
}, (myArg) => { | |
console.log(myArg) | |
}) | |
getData(myArg) | |
const getData2 = server$((myArg) => { | |
console.log(myArg) | |
}) | |
getData2(myArg) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getData = server$((myArg) => { | |
console.log(myArg) | |
}, { | |
method: 'get' | |
}) | |
getData(myArg) |
ha thats very JavaScript
I don't want to recreate all the fetch options 😩 also typing that would be insane
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.
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
This would be even better: