Closed FWennerdahl closed 8 years ago
I'll take a look at resolving the merge conflicts in this as soon as possible.
You're 100% right that Typo should be able to operate asynchronously. The reason it doesn't is because I was lazy when I wrote the first version, and at that point, Chrome allowed synchronous requests, so it was easier to just do it that way.
I'm going to look at merging your changes into the latest code tonight.
All of your changes are merged as of 1f5e5f9c2f1549309ad7715c44a4f9a4f4f4c7c1. Thanks!
Awesome, thanks!
@FWennerdahl Would you like to have commit access? This changeset was merged a while ago, and I don't know if you're still using Typo, but you've shown yourself to understand its workings, so I'd be happy to grant you write access if you'd like it.
Running Typo.js in a Chrome App is not currently possible since synchronous XMLHttpRequests are prohibited. The following error is thrown when trying to load a dictionary:
In order to be able to run Typo.js in a Chrome App (and to improve the user experience overall since synchronous requests block the UI) I implemented an option in the Typo constructor settings to make XMLHttpRequest asynchronously. This is implemented in a backwards-compatible manner. Existing code will still make synchronous calls unless they specify
asyncLoad: true
.Notes:
fs.readSync
is still used regardless of the value of theasyncLoad
setting.lib/typo/dictionaries/
totypo/dictionaries/
. As it were, the en_US dictionary was not found out of the box when instantiating Typo without preloaded data. This could break backwards-compatibility for users who have manually placed their dictionaries in thelib/typo/dictionaries/
folder. If this path is not to be changed I would suggest moving the en_US dictionary files so that Typo can find them by default.Further reading regarding synchronous vs. asynchronous XMLHttpRequests: https://developers.google.com/web/updates/2012/01/Getting-Rid-of-Synchronous-XHRs http://blogs.msdn.com/b/wer/archive/2011/08/03/why-you-should-use-xmlhttprequest-asynchronously.aspx