在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:koajs/bigpipe-example开源软件地址:https://github.com/koajs/bigpipe-example开源编程语言:JavaScript 81.7%开源软件介绍:BigPipe ExampleAn app built with koa and component that implements Facebook's BigPipe. Given a subreddit, this app does the following:
In total, that is 7 asynchronous calls with the request to imgur being the slowest. Installation and SetupThis example requires node v0.11.3+ for generator support. Here's an example installation: # Install and use node v0.11
nvm install 0.11
nvm use 0.11
# Clone this example
git clone git://github.com/jonathanong/bigpipe-example
cd bigpipe-example
# Install all dependencies and build the assets
npm install
# Start the server. Serves on port 3456 by default
npm start StrategiesThis example implements 3 strategies. The strategies are listed from slowest to fastest and worst to best. This app is designed to be able to switch between any of these 3 modes with minimal code. These strategies are all implemented as streams. If you want to implement caching, you would want to buffer the result and process it before sending it to the client. Fortunately, this is easy with koa. SequentialAll asynchronous functions are blocking and are called within the template. This is the easiest way to build a webpage and is similar traditional web languages like PHP, Ruby, and Python. This is actually difficult to do in vanilla node.js, but very easy with koa. ParallelAll asynchronous functions are executed before the rendering of the template.
This is similar to traditional Express apps where rendering occurs at BigPipeAll asynchronous functions are executed after the initial layout is flushed to the client so the client will see a barebone layout immediately. Each asynchronous function, also called a pagelet, is rendered and pushed independently to the client. Each pagelet is generally self-contained, meaning it has its own HTML, JS, CSS. The major downside to BigPipe is that it requires Javascript on the client and HTTP caching is pretty much impossible. BigPipe should be used only for dynamic content. KoaKoa is a new generator-based framework based on co and is the spiritual successor to express. By using generators for control flow, there's no more callback hell or painful error handling. Look at the source code to see for yourself. ComponentComponent is a CommonJS-based client-side package manager and build system.
Not only does it allow you to easily consume 3rd party components (packages of JS, CSS, HTML, images, fonts, etc.),
it also allows you to organize your app as independent components.
No more Architecture
LicenseThe MIT License (MIT) Copyright (c) 2013 Jonathan Ong [email protected] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论