We are developing a JSDO access module in Angular 2. Using a progress.js and progress.d.ts library.
After getting more familiarity with jsdo for angular 2, we figured out the progress.d.ts and progress.js v.4.3.0 are outdated.
We get the project from: community.progress.com/.../3124
We wonder if is available a new version of progress.d.ts for JSDO v4.3.1
progress.d.ts:
// Type definitions for progress.js v4.0
//
// Author(s): egarcia
//
Hello William,
The original progress.d.js file has not been updated to 4.3.x.
However, Lars Neumeier has a branch with a version updated to 4.3.0:
community.progress.com/.../95193
i will look into getting the typings updated and available via GitHub.
BTW, how are you handling promises?
Do you include jQuery?
You might be interested in the following sample that uses native JavaScript Promises:
community.progress.com/.../3190
I hope this helps.
Thank you and regards,
Edsel
Hello Edsel.
Actually, we are not using progress.data.JQueryPromise. We are subscribing CRUD, Submit and Invoke methods using subscribe() from JSDO.
Even using jsdo (4.3) from npm, the typings do not correspond to the docs. The progress.data.Session typings hasn`t implemented login(parameter-object) so it forces sync operations (only on login) and we are having issues for that.
We are going to try implement JQuery and use progress.data.JSDOSession and try async login.
Do you have any sugestion for us?
Best Regards,
William Antero
Hello William,
Could you provide more details on the issues that you are having?
The login(parameter-object) method in the Session object was omitted from the typings.
You could add it manually, if you need.
In general, for asynchronous login(), it is better if you use the JSDOSession object.
JQuery is used for Promises. The JQueryPromise in the typings defines an interface for it.
You can use another iibrary for Promises.
The following example provides a wrapper object (in file pwrapper.js) to use native JavaScript Promises:
community.progress.com/.../3190
You could also use a wrapper object for the Q library to provide support for Promises.
For the JSDO object, you can subscribe to events or use Promises to handle asynchronous operations. You can also use events and Promises together if it is convenient.
I hope this helps,
Edsel
Hello Edsel,
JQuery is unfortunately a dependency for the JSDO, because it is directly used bei the JSDO.
Hello William,
As far as I can see, the login function takes some parameters and checks wether the first argument is an object and assigns the variables from the properties, but I have not updated Session, because I was always usings JSDOSession.
-
I will update typings and npm to 4.3.1 JSDO release.
Hello Lars,
Have you had a chance to use the sample on using the JSDO with native JavaScript Promises?
Link:
community.progress.com/.../3190
There you will see that using the pwrapper.js file, you can obtain Promise support compatible with the one provided in jQuery.
There is also an option to use the Q library for Promises. You would need another wrapper file for it.
Please let me know if you would like to use the the wrapper file for Q.
Thanks,
Edsel
Hello Edsel,
No, I have not tried this example, but I will look into it. In the meantime, I created a pull request for npm-package definition and TypeScript definitions.
Hello Lars,
Thank you for submitting the pull request.
We will review it and process the pull request.
Thanks again,
Edsel
Hello, Lars and Edsel!
We are having some progress here.
By importig pwrapper into progress.js as a workaround we no more need to implement jquery in our angular2 project.
A code sample of our injectable JSDO class
constructor(private http: Http) {
this._serviceURI = '<<SERVICE_URI>>';
this._catalogURI = '<<CATALOG_URI>>';
this._session = new progress.data.JSDOSession({
serviceURI: this._serviceURI,
authenticationModel: progress.data.Session.AUTH_TYPE_FORM
});
}
public addCatalog(){ //RETURNING PROMISE TO NGMODULE HANDLE IT
return this._session.addCatalog(this._catalogURI, 'user', 'pass');
}
public login(username?: string, password?: string) {
let that = this,
promise = that._session.login("user","pass");
promise.done((session, result)=>{
console.log('logged in', result);
})
}
/** CRUD OPERATIONS OMITTED **/
We get the data and all operations occurs fine, but we get this error at the first load.
TypeError: deferred.resolve is not a function
at Object.resolve (pwrapper.js:48)
at XMLHttpRequest.JSDO._invokeComplete [as onCompleteFn] (progress.js:3123)
at XMLHttpRequest.JSDO.onReadyStateChangeGeneric (progress.js:6735)
at XMLHttpRequest.wrapFn [as _onreadystatechange] (zone.js:1190)
at ZoneDelegate.webpackJsonp.1037.ZoneDelegate.invokeTask (zone.js:363)
at Object.onInvokeTask (ng_zone.js:264)
at ZoneDelegate.webpackJsonp.1037.ZoneDelegate.invokeTask (zone.js:362)
at Zone.webpackJsonp.1037.Zone.runTask (zone.js:166)
at XMLHttpRequest.ZoneTask.invoke (zone.js:416)
Have you any idea what's about?
Hello Renato,
> TypeError: deferred.resolve is not a function
What web browser are you using?
It looks like the resolve parameter passed to the creation of the Promise in line 18 is not a function.
What does it look like?
I would expect two functions to be passed to this constructor.
See developer.mozilla.org/.../Promise
I hope this helps,
Edsel
Maybe progress.js is calling $ promise without passing resolving/rejecting parameters. I just handle it adding this two lines of code:
line 48 pwrapper.js
resolve: function () {
if (deferred.resolve) <<
deferred.resolve(arguments);
},
reject: function () {
if (deferred.reject) <<
deferred.reject(arguments);
}
and everything seems work fine. Not sure if I can have issues later with it.
The code that you added to make the exception go a way.
However, the deferred.resolve and deferred.reject are expected to be defined as a function.
Here is what I see in Visual Studio Code when running it the Node.js code.
Please notice that the reject and resolve parameters point to functions with native code.
What do you see in your environment as the value for resolve and reject?