Are there any guidelines on when to use Promise.sync() and Promise.value()?
is the value in Promise.value() 'evaluated' everytime the Promise is resolved?
if so then whats the difference between Promise.sync() and Promise.value()?
My use case:
when returning a function that operates on Ratpack context is returned as a Promise via sync(), the unit tests relying on it via RequestFixture fails (the code from sync() actually returns a NullPointerException). when the same function is returned via value(), unit test works as expected.
Many thanks for a wonderful library!
Promise.sync() takes a function, that is invoked every time the promise is subscribed to. You can think of Promise.value() as syntactic sugar for Promise.sync() where the function always returns that value.
Regarding the NPE, my guess is that you're effectively doing Promise.sync(null), which will indeed throw an exception.