Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breeze js without Q library for knockoutjs ? #68

Open
rangarks opened this issue Jun 2, 2022 · 3 comments
Open

Breeze js without Q library for knockoutjs ? #68

rangarks opened this issue Jun 2, 2022 · 3 comments

Comments

@rangarks
Copy link

rangarks commented Jun 2, 2022

Hi,

I am working on integrating some custom components written in blazor with an old .net mvc knockoutjs application. We are using breeze for Odata calls to our api.
Breeze uses Q library to resolve promises and due to which traditional JS promises are having some sort of side effects due to which, "instance of Promise" always evaluates to false, even if the variable is a promise.

I am curious, to know if there's a way to implement breeze without using the Q library for .mvc Knockout applications !

Any suggestions are greatly appreciated

@marcelgood
Copy link

The latest version of breeze-client no longer uses Q. We've rewritten Breeze in TypeScript and are using ES6 promises now. I would recommend you upgrade to the latest version.

However, if you don't want to do it at this point, then yes you can replace Q with your own promise service using whatever promise implementation you like.

You can find an example in our old Angular bridge.

Here's the ES6 promise adapter: https://github.com/Breeze/breeze.bridge.angular/blob/master/src/common.ts

and then you just have to plug it in with config.setQ as shown here on line 15: https://github.com/Breeze/breeze.bridge.angular/blob/master/src/module.ts#L15

@rangarks
Copy link
Author

rangarks commented Jun 7, 2022

@marcelgood - Thank you so much for responding, I was looking to update my breeze to latest version. I am using knockout js so previously app was directly referencing the scripts directly. Now to update I am following this guide here - https://github.com/Breeze/breeze-client/blob/master/UPGRADE.md

After directly referencing the files in my layout.cshtml, is this a right way to do ? Mine is an old .net mvc knockout application.

@marcelgood
Copy link

marcelgood commented Jun 7, 2022

Yes, that's pretty much the way to go if you modernize your JavaScript or upgrade to TypeScript. You can also still reference the UMD scripts directly as shown at the end. We haven't used knockout in a long long time, and it's no longer the default, so you'll have to register the ModelLibraryKnockoutAdapter instead of the ModelLibraryBackingStoreAdapter used in the upgrade guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants