Comments (10)
from hprose-js.
CommonJS is very useful on:
- Server-side JavaScript applications
- Command line tools
- Desktop GUI-based applications
- Hybrid applications (Titanium, Adobe AIR)
But hprose-js can only work on browser-applications, it can't work on server-side.
hprose-nodejs is a node.js (CommonJS) module, it can work on everywhere except browser.
hprose-html5 is another hprose implementation for browser-applications, and it also can work on Hybrid applications (Titanium, Adobe AIR, cocos2d-js jsb applications). I added requirejs and seajs support for this version.
I think to add requirejs and seajs support for hprose-js is more useful than making hprose-js aware of CommonJS. Do you think so?
Best regards,
Ma Bingyao
from hprose-js.
RequireJS - which basically is CommonJS - is becoming very, very popular these days. In fact, jQuery, for instance, handles both styles, AMD and CommonJS at once, and allows to be ran inside NodeJS if a window-like object can be specified
, so they say.
What I would suggest for hprose-js is that it implements at least CommonJS. It gives developers the option to smoothly move their code to another platform without losing much features or having a big burden of converting their code.
Actually I don't know what the difference between hprose-js and hprose-html5 is. It looks very similar from a short glance.
So my opinion is, that you should add RequireJS support, since that is pretty much CommonJS.
Here is a little template that can maybe help you with getting this going:
(function(root, construct){
if(typeof module != "undefined" && typeof exports == "object") {
module.exports = construct();
} else {
root.hprose = construct();
}
})(this, function(){
// hprose code goes here. Here is an example:
var hprose = {};
hprose.foo = function() {}
return hprose;
// A module that require()'d this file now gets the hprose object.
});
Kind regards, Ingwie.
from hprose-js.
features | hprose-js | hprose-html5 | hprose-nodejs |
---|---|---|---|
binary data | ❌ | ✅ | ✅ |
browser applications | ✅ | ✅ | ❌ |
old browser | ✅ | ❌ | ❌ |
cross domain | flash & cors | cors | ✅ |
http client | ✅ | ✅ | ✅ |
tcp client | ❌ | ✅ | ✅ |
unix socket client | ❌ | ❌ | ✅ |
websocket client | ❌ | ✅ | ✅ |
Server-side applications | ❌ | maybe | ✅ |
Command line tools | ❌ | maybe | ✅ |
Desktop GUI-based applications | maybe | ✅ | ✅ |
Hybrid applications (Titanium, Adobe AIR) | maybe | ✅ | ✅ |
http service/server | ❌ | ❌ | ✅ |
tcp service/server | ❌ | ❌ | ✅ |
unix socket service/server | ❌ | ❌ | ✅ |
websocket service/server | ❌ | ❌ | ✅ |
Completer/Future async | todo | ✅ | ✅ |
RequireJS(AMD) | todo or not | ✅ | ❌ |
SeaJS(CMD) | todo or not | ✅ | ❌ |
CommonJS | ❌ | ✅ | ✅ |
global HproseXXX (such as HproseClient) | ✅ | ❌ | ✅ |
hprose.XXX (such as hprose.Client) | ❌ | ✅ | ✅ |
hprose-js and hprose-html5 have different API interface, because we want they can work together without conflict.
The significance of the existence of hprose-js is only in order to be compatible with old browsers.
hprose-nodejs is compatible with the above two kinds of API interface. so if the developers want to move the hprose-js or hprose-html5 application to another platform, they don't need to converting any code, only to change the hprose-js or hprose-html5 to hprose-nodejs. and there is no feature losing, instead, they will get more features.
jQuery need to handle AMD and CommonJS at once, because it only have one implementation.
Hprose don't need to handle AMD and CommonJS at once, because hprose have three implementation.
But I can add CommonJS support to hprose-html5, because it is easy to do and more useful than hprose-js.
Best regards,
Ma Bingyao
from hprose-js.
Oh I see! So if hprose-js is ment for older browsers, then I am likely better off when using hprose-html5.
In the long run, you should consider if it maybe isnt easier to merge the two together instead of maintaining two similar, but not similar, projects at the same time.
For now, I'd suggest adding the CommonJS/AMD support since many people seem to use it. One great usage is WebPack which I am successfuly using in my BIRD3 project - it makes many things much easier.
from hprose-js.
I will add CommonJS support for hprose-html5, tonight.
from hprose-js.
from hprose-js.
Completer/Future async is come from dart language.
It is very similar to Promises/A+.
But I simplify its implementation. I only reserved the following methods and properties:
class | method |
---|---|
Completer | constructor |
Completer | complete |
Completer | completeError |
Future | then |
Future | catchError |
class | property |
---|---|
Completer | future |
for example:
var completer = new Completer();
var client = new hprose.Client.create('http://hprose.com/example/');
client.then(function(stub) {
stub.hello('World')
.then(function(result) {
completer.complete(result);
})
.catchError(function(e) {
completer.completeError(e);
})
})
.catchError(function(e) {
console.error(e);
})
...
var future = completer.future;
future.then(function(result) {
console.info(result);
})
.catchError(function(e) {
console.error(e);
})
and I will add this feature in PHP, too, with this feature, we can publish an async service.
from hprose-js.
I already have added CommonJS support for hprose-html5, just now.
from hprose-js.
hprose for javascript is update.
features | hprose-js | hprose-html5 | hprose-nodejs |
---|---|---|---|
binary data | ✅ | ✅ | ✅ |
browser applications | ✅ | ✅ | ❌ |
old browser | ✅ | ❌ | ❌ |
cross domain | flash & cors | cors | ✅ |
http client | ✅ | ✅ | ✅ |
tcp client | ✅ | ✅ | ✅ |
unix socket client | ❌ | ❌ | ✅ |
websocket client | ✅ | ✅ | ✅ |
Server-side applications | maybe | maybe | ✅ |
Command line tools | maybe | maybe | ✅ |
Desktop GUI-based applications | ✅ | ✅ | ✅ |
Hybrid applications (Titanium, Adobe AIR) | ✅ | ✅ | ✅ |
http service/server | ❌ | ❌ | ✅ |
tcp service/server | ❌ | ❌ | ✅ |
unix socket service/server | ❌ | ❌ | ✅ |
websocket service/server | ❌ | ❌ | ✅ |
Completer/Future async | ✅ | ✅ | ✅ |
RequireJS(AMD) | ✅ | ✅ | ❌ |
SeaJS(CMD) | ✅ | ✅ | ❌ |
CommonJS | ✅ | ✅ | ✅ |
global HproseXXX (such as HproseClient) | ✅ | ❌ | ✅ |
hprose.XXX (such as hprose.Client) | ✅ | ✅ | ✅ |
from hprose-js.
Related Issues (9)
- 关于js客户端推送 HOT 1
- 刚学这个 请问一下 HOT 9
- 请问后续提供js作为被调用方(即服务端)的支持么? HOT 1
- Is javascript Client work on web browser with websocket? HOT 3
- star数量这么少,我想知道您持续更新的动力在哪 HOT 5
- crossdomain.xml这个文件怎么用,我一直有跨域报错的问题 HOT 1
- setHeader跨域 HOT 5
- hprose js 和 hprose html5 的区别是? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hprose-js.