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

Do partial.js support flush #30

Closed
goldalworming opened this issue Aug 21, 2013 · 34 comments
Closed

Do partial.js support flush #30

goldalworming opened this issue Aug 21, 2013 · 34 comments
Labels

Comments

@goldalworming
Copy link

Do partial.js supprot flush to send and how to combine with the layout?

the case study is

  • I get request query for the head and navigation data
  • instead of waiting the next query, I want to flush it then do the next query

Do you support it?

@petersirka
Copy link
Collaborator

You can use a "partial content":

Example:
https://github.com/petersirka/partial.js/tree/master/examples/routing-partial

Partial content is asynchronous. You can load data from DB and wait for the result. Partial content can be global or specific. All views are synchronous.

Or use async feature:

Example:
https://github.com/petersirka/partial.js/tree/master/examples/async


If you don't understand I'll write an example.

@goldalworming
Copy link
Author

I failed to run async examples..
408: Request Timeout in web browser
and
waiting 1 complete
waiting 2 complete
in console...what is it async??

@petersirka
Copy link
Collaborator

Asynchronous work is longer as default timeout:

  1. you can set up default timeout in the framework config file (default-request-timeout = 3000 (default - 3 seconds)
  2. or you can set up default timeout in the definition of route:

Example:
https://github.com/petersirka/partial.js/tree/master/examples/routing-timeout


What is async?

Async is a class for asynchronous work. Async class helps you to do several things at the same time.

@goldalworming
Copy link
Author

I think flush is partial content but sending it without waiting after all part finishing the execution..

or can you give example partial content using 'get started examples'?.
I think it will closer to real world app.
because we often separate header query execution, body and the rest of page..

in get started examples, it's only separate the template..not the execution..
http://www.partialjs.com/get-started/

@petersirka
Copy link
Collaborator

I'm writing a new documentation. There will a complete explanation.
Thanks.

@goldalworming
Copy link
Author

thank you..

@goldalworming
Copy link
Author

the best framework examples I've ever seen is tornadoweb examples..
although I it doesn't give file structure example...

@petersirka
Copy link
Collaborator

Thanks - I'll look.

@goldalworming
Copy link
Author

sorry for OOT but do you have examples of login with google, twitter, facebook, etc..
or it's better for me to use other library like everyauth??

@petersirka
Copy link
Collaborator

Hi @goldalworming,
Yes, it's better use other library. I found big problem with authorization and today (evening) I'll update NPM partial.js package - so then update your partial.js. I'll write example with oauth.

Thanks.

@goldalworming
Copy link
Author

I hope it won't take a long time..

@petersirka
Copy link
Collaborator

I'll write an example and update partial.js version today.

@goldalworming
Copy link
Author

thanks a lot...

@petersirka
Copy link
Collaborator

Hi @goldalworming,
I updated the version. Download: https://github.com/petersirka/partial.js/releases/tag/1.2.5-1

I'm preparing an example of OAuth, please write me - Which module of OAuth do you use?

@goldalworming
Copy link
Author

thanks, I've updated partial.js..
I tried everyauth, but some stackoverflow's QA direct me to passport..(http://stackoverflow.com/questions/11974947/everyauth-vs-passport-js)
I think use passport would better for example..

@petersirka
Copy link
Collaborator

Super, I'll write an example with the passport.js today.

@petersirka
Copy link
Collaborator

I looked on the passport.js and everyauth. Modules are written for Express.js and this is a problem. I must write own auth for Google, Facebook, Twitter and OpenID. Other modules haven't good documentation.

Really sorry, I have no more time.

@goldalworming
Copy link
Author

ok,no problem..thanks..

and do you have any explanation about #.js
in auth examples thereis onValidation function and onAuthorization but when then function called

if self.validate will call onValidation..so when onAuthorization called..

@petersirka
Copy link
Collaborator

Yes ...

onValidation:

onValidation = is for object / values validation
self.validate(object) == read all properties and on each property call onValidation.


onAuthorization:

Is called when a route has contain "logged" / "unlogged" flag.

Thanks.

@goldalworming
Copy link
Author

can we make own flag like 'admin' / 'notadmin' or anything else??

@petersirka
Copy link
Collaborator

You can use "role route flags".

Example:
https://github.com/petersirka/partial.js/tree/master/examples/routing-flags-roles

@goldalworming
Copy link
Author

that's very neat...thank you..

@goldalworming
Copy link
Author

Hi, I want to back on flushing issue..

after adding timeout in async example..and try some examples..

flushing is like server-sent-event / websocket send data to client with template..but using sse / websocket will give me browser support problem..do you have any alternative??

@petersirka
Copy link
Collaborator

Hi @goldalworming,
there is only one alternative: XHR, but partial.js doesn't support pooling between SSE/WebSocket and XHR. You must write this feature :-)

@goldalworming
Copy link
Author

I don't understand pooling between SSE/Websocket and XHR..does it mean partial.js not support XHR and Websocket in one app??

@petersirka
Copy link
Collaborator

partial.js supports SSE/WebSocket/XHR in one app. You must write a shared communication between SSE/WebSocket/XHR.

TIP:
Write a custom module in partial.js and on each request (SSE/WebSocket/XHR) call a module.

@goldalworming
Copy link
Author

I thought redis would be enough as database to make communication between them..Does it wrong?
or what kind shared communication do you mean?

does socket.io library doesn't work with partial? (#20)

@lgruz
Copy link
Contributor

lgruz commented Sep 24, 2013

Socket.io works perfectly with partial.js

@goldalworming
Copy link
Author

@Igruz : how do you write the socket.io route and the function??

@lgruz
Copy link
Contributor

lgruz commented Sep 24, 2013

I created a module named "websocket":

var socketio = require('socket.io');

framework.on("load", function() {
this.ws = socketio.listen(this.server);
});

Then, in config file you have to set "allow-websocket" as false. Now, you can use framework.ws in any route, module...

@goldalworming
Copy link
Author

ok I'll try it..

@goldalworming
Copy link
Author

Hi, for google auth..is this library fit with partial.js??
https://github.com/ciaranj/node-oauth
or is it too old?
I read this article use it...http://www.jonathanbroquist.com/blog/2013/10/building-a-google-calendar-booking-app-with-mongodb-expressjs-angularjs-and-node-js-part-1/

@petersirka
Copy link
Collaborator

Hi @goldalworming,

Potentially can use node-oauth, but it is not guaranteed. You can rewrite (in its examples):

res (response) -> controller.res;
req (request) -> controller.req;

If you use controller.res somewhere then before using you must call controller.close() for preventing of timeout. Please give me a feedback about using node-oauth according to article.

PS: I wrote Login with Facebook (https://github.com/petersirka/partial.js-modules/tree/master/facebook)

Thanks!

@goldalworming
Copy link
Author

hello, sorry for trigger old issues
what do you think about this example
is it possible to make it in total.js

http://neethack.com/2013/01/express-bigpipe-experiment/

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

No branches or pull requests

3 participants