Skip to content

Commit b71918f

Browse files
committed
GPII-228 Combined gpii.flowManager getSolutions and getSolutionsPromise
1 parent 53ae908 commit b71918f

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

gpii/node_modules/flowManager/src/Capture.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ fluid.defaults("gpii.flowManager.capture", {
2929
args: ["{flowManager}.deviceReporter"],
3030
priority: "first"
3131
},
32-
"onSolutionsForCurrentDevice.getSolutionsPromise": {
33-
funcName: "gpii.flowManager.getSolutionsPromise",
32+
"onSolutionsForCurrentDevice.getSolutions": {
33+
funcName: "gpii.flowManager.getSolutions",
3434
args: [ "{flowManager}.solutionsRegistryDataSource", "{arguments}.0"],
3535
priority: "after:getDeviceContextPromise"
3636
},
3737
"onSolutionsForCurrentDevice.solutionsRegistryEntriesToPromise": {
3838
funcName: "fluid.toPromise",
3939
args: ["{arguments}.0.solutionsRegistryEntries"],
40-
priority: "after:getSolutionsPromise"
40+
priority: "after:getSolutions"
4141
},
4242
// Begin declaration of Promise Chain for onCaptureSettingsForCurrentDevice
4343
"onCaptureSettingsForCurrentDevice.getInstalledSolutionsForCurrentDevice": {

gpii/node_modules/flowManager/src/MatchMaking.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -78,29 +78,23 @@
7878
};
7979

8080
/*
81-
* Asynchronous function which makes a get call to the solutions registry (1st parameter) to
81+
* Asynchronous/Promise returning function which makes a get call to the solutions registry (1st parameter) to
8282
* retrieve the solutions registry matching what is passed in the `device` parameter.
8383
* This is appended to the matchmaker payload (mmpayload) parameter, which in turn is passed
8484
* as parameter in the event fired.
8585
*
86+
* This function can be used with either (or both) asyncronously with an `event` and `onError` handlers
87+
* passed in, or with the returned `fluid.promise`.
88+
*
8689
* @solutionsRegistryDataSource (Object) - a solutions registry data source
8790
* @deviceContext (Object) - output from a device reporter. Used to filter solutions registry entries
88-
* @event (Object) - Event to be fired when the solutionsRegistry entry has been retrieved
89-
* @onError (Object) - Event to be fired when an error occurs
91+
* @event (Object) - Optional: Event to be fired when the solutionsRegistry entry has been retrieved
92+
* @onError (Object) - Optional: Event to be fired when an error occurs
9093
*
91-
* @return (undefined) - function is asynchronous and doesn't return anything. Instead the event
92-
* is fired with the modified mmpayload.
94+
* @return (fluid.promise) - Returns a promise resolving with the mmpayload . Optionally if provided, the events
95+
* are also fired with the modified mmpayload.
9396
*/
9497
gpii.flowManager.getSolutions = function (solutionsRegistryDataSource, deviceContext, event, onError) {
95-
gpii.flowManager.getSolutionsPromise(solutionsRegistryDataSource, deviceContext).then(
96-
function (data) {
97-
event.fire(data.solutionsRegistryEntries, data.solutions);
98-
},
99-
onError.fire
100-
);
101-
};
102-
103-
gpii.flowManager.getSolutionsPromise = function (solutionsRegistryDataSource, deviceContext) {
10498
var promiseTogo = fluid.promise();
10599

106100
var os = fluid.get(deviceContext, "OS.id");
@@ -112,7 +106,15 @@
112106
solutionsRegistryEntries: solutionsRegistryEntries,
113107
solutions: solutions
114108
});
115-
}, promiseTogo.reject);
109+
if (event) {
110+
event.fire(solutionsRegistryEntries, solutions);
111+
}
112+
}, function (error) {
113+
promiseTogo.reject(error);
114+
if (onError) {
115+
onError.fire(error);
116+
}
117+
});
116118

117119
return promiseTogo;
118120
};

0 commit comments

Comments
 (0)