I wrote my own promise and want to chain it, but the result is always only the first in the chain. I think there is an understanding issue on my side how to use them, but I don't able to find it.
My Code:
-(PMKPromise*)tryTheFirstPromiseWorkflow:(TestCycleObject *)testCycleObject{
PMKPromise *promise = [PMKPromise new:^(PMKPromiseFulfiller fulfill, PMKPromiseRejecter reject) {
fulfill(PMKManifold([_addModul addSomething:testCycleObject]));
}];
promise.then(^(TestCycleObject *testCycleObject){
testCycleObject = [_addModul addSomething:testCycleObject];
NSLog(@"Result: %i, Fulfilled: %d", testCycleObject.result, promise.fulfilled);
return testCycleObject;
}).then(^(TestCycleObject * testCycleObject){
testCycleObject = [_multiModul multiSomething:testCycleObject];
NSLog(@"Result: %i, Fulfilled: %d", testCycleObject.result, promise.fulfilled);
return testCycleObject;
}).then(^(PMKPromiseFulfiller fulfill, PMKPromiseRejecter reject){
fulfill(testCycleObject);
});
return promise;}
At first I create the promise, then the chain starts, but after creating the promise it will deliver only the action passed in the promise initialization and not the chain as result.
I tried your purpose, but still run into an issue:
-(void)test{
PMKPromise *test = (PMKPromise*)[self tryTheFirstPromiseWorkflow: [[TestCycleObject alloc] initWithDefaultValues]];
TestCycleObject *temp = (TestCycleObject*) test.value;
NSLog(@"Test: %i", temp.result);
}
This is how I call the promise, but the result of it is always empty. The promise is executed after my log, but then I can't fetch the result. So how can I get the result in my method. I thought the method have to stop until the promise is running, am I wrong?