Re: first time without state - and I'm lost

2020-06-16 Thread Oleksandr Shulgin
On Mon, Jun 15, 2020 at 7:34 PM Ernesto Garcia wrote: > Hi, it's a long time that this question was posted, but I have found it > interesting in the implementation of token refreshes. > > First of all, for service invocation, given a `revise-oauth-token` method, > I think this is good client code

Re: first time without state - and I'm lost

2020-06-15 Thread Ernesto
That's nice. We could do something like: (-> (swap! ...) force :access_token) On Mon, Jun 15, 2020 at 7:57 PM Justin Smith wrote: > The usage of delay here is clever. I suggest as an addition, using > `force` instead of `deref` to disambiguate delay vs. atom (of course > if you take a few m

Re: first time without state - and I'm lost

2020-06-15 Thread Justin Smith
The usage of delay here is clever. I suggest as an addition, using `force` instead of `deref` to disambiguate delay vs. atom (of course if you take a few moments to think about it, swap! shouldn't return an atom etc., but I think it becomes clearer with force). On Mon, Jun 15, 2020 at 10:34 AM Ern

Re: first time without state - and I'm lost

2020-06-15 Thread Ernesto Garcia
Hi, it's a long time that this question was posted, but I have found it interesting in the implementation of token refreshes. First of all, for service invocation, given a `revise-oauth-token` method, I think this is good client code: (http/request {:method :get :url "https://example.com/

Re: first time without state - and I'm lost

2020-06-04 Thread Gary Johnson
Hi Scaramaccai, Several posters in this thread have given you example code for how to solve your OAuth token problem in Clojure. Perhaps I can add to this discussion by pointing out the fundamentals of functional programming that can help you decide how to solve problems like this. *Loops -> Recu

Re: first time without state - and I'm lost

2020-05-14 Thread J.-F. Rompre
Hi @Scaramaccai, If you are starting out, it's always best to keep things as bare as possible until you discover a better way. If as you say you can save the usr/pwd, and the decision to keep or replace the token is entirely left to the token provider, then I think something like the following

Re: first time without state - and I'm lost

2020-05-14 Thread J.-F. Rompre
Hi @Scaramaccai, If you are starting out, it's always best to keep things as bare as possible until you discover a better way. If as you say you can save the usr/pwd, and the decision to keep or replace the token is entirely left to the token provider, then I think something like the following

Re: first time without state - and I'm lost

2020-05-14 Thread J.-F. Rompre
Hi @Scaramaccai, If you are starting out, it's always best to keepthings as bare as possible until you discover a better way. If as you say you can save the usr/pwd, and the decision to keep or replace the token is entirely left to the token provider, then I think something like the following

Re: first time without state - and I'm lost

2020-05-14 Thread J.-F. Rompre
Hi @Scaramaccai, If you are starting out, it's always best to keepthings as bare as possible until you discover a better way. If as you say you can save the usr/pwd, and the decision to keep or replace the token is entirely left to the token provider, then I think something like the following

Re: first time without state - and I'm lost

2020-05-14 Thread J.-F. Rompre
Hi @Scaramacci, If you are starting out, it's always best to keep things as bare as possible until you discover a better way. If as you say you can save the usr/pwd, and the decision to keep or replace the token is entirely left to the token provider, then I think something like the following

Re: first time without state - and I'm lost

2020-05-13 Thread James Reeves
On Wed, 13 May 2020 at 12:16, Matthew Downey wrote: > The most similar thing you could do to your Java code would be keeping > the token in an atom inside of a connection record. > As a quick note, if you don't need polymorphism, maps should be favoured over records. -- James Reeves booleankno

Re: first time without state - and I'm lost

2020-05-13 Thread Matthew Downey
I totally understand that, I felt the same way first coming to Clojure. For this situation, there are a couple approaches that you could take depending on how hardcore you want to be about keeping things functional & immutable. The most similar thing you could do to your Java code would be keepin

first time without state - and I'm lost

2020-05-12 Thread Gerard Klijs
What helped for me was picking an existing Clojure project, and try to make changes to it. I also struggled with some things. And not declaring and mutating objects was confusing at times. But I think with this regard it helped me a lot. In my case it was an existing cljs snake game https://gi

Re: first time without state - and I'm lost

2020-05-12 Thread Jag Gunawardana
I know that lost feeling. I came from a background of OO too. Most of the languages I'd used (C++, Java, Python, Go) had either total OO orientation, or at least pushed you into an OO way of thinking. I found that reading some Clojure books and other's code helped a lot (Joy of Clojure, Eric N

Re: first time without state - and I'm lost

2020-05-12 Thread Orestis Markou
I’m interested in this too — you can get inspiration from https://github.com/cognitect-labs/aws-api/blob/master/src/cognitect/aws/credentials.clj which does something similar for expired credentials. Seems

first time without state - and I'm lost

2020-05-12 Thread Scaramaccai
Hi everyone, I wanted to give a try to Clojure and functional programming in general but I can't really stop thinking "object oriented" or "with state everywhere". After 20+ years with objects + state I guess I'm lost without them :) The first thing I want to try is to get some data from an API