Closed cbbfcd closed 6 years ago
Offical have no plan for stream render right now. If you have rest time welcome to pull request it! By the way you can read this post https://imququ.com/post/reduce-ttfb-on-thinkjs3-website.html to achieve stream display feature in your project.
Thank you for your suggestion, I will try to achieve it
@lizheming i found a funny UI lib which called markojs。
some code like this:
require('marko/node-require');
const { createGzip } = require('zlib');
const Koa = require('koa');
const app = new Koa();
const template = require('./index.marko');
app.use((ctx, next) => {
ctx.type = 'html';
ctx.body = template.stream({
name: 'Frank',
count: 30,
colors: ['red', 'green', 'blue']
});
ctx.vary('Accept-Encoding');
if (ctx.acceptsEncodings('gzip')) {
ctx.set('Content-Encoding', 'gzip');
ctx.body = ctx.body.pipe(createGzip());
}
});
app.listen(8080);
Ctx.body itself supports stream, so if I think, if a template engine supports stream output, it is indirectly implementing support for stream。 So what I think is from the think-view, I don’t know if I’m totally wrong.
think-view
just an extend for ThinkJS, we can use thinkjs without think-view
absolutely. As your code show, you can use markojs directly in ThinkJS, or you can wrap markojs to an extend named like think-marko
.
yep! i will try! thx!
feature
as the title, there are any plan?