Skip to content

Instantly share code, notes, and snippets.

@pajlada
Created October 26, 2017 12:43
Show Gist options
  • Save pajlada/dd2e2afe93daaf7b2b25fd0ed7473850 to your computer and use it in GitHub Desktop.
Save pajlada/dd2e2afe93daaf7b2b25fd0ed7473850 to your computer and use it in GitHub Desktop.
void main()
{
/// Old way
NetworkManager::urlFetch(QUrl("google.com"), [](auto reply) {
// do shit with reply
});
// or
NetworkManager::urlFetch(QNetworkRequest("google.com"), [](auto reply) {
// do shit with reply
});
// or
NetworkManager::urlFetch(QUrl("google.com"), caller,
[](auto reply) {
// do shit with reply on finished
},
[](auto reply) {
// do initial shit with reply
});
/// New way
NetworkRequest req("google.com");
// or NetworkRequest req("google.com", caller);
req.onReplyCreated = [](auto reply) {
// handle when the reply is created
};
req.start([](auto reply) {
// on reply finished
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment