最近在做demo的时候使用了koa框架,自己做了一个静态服务器,首先判断访问文件是否存在,在回调函数中设置了this.body,run之后,各种404,花了N长的时间把koa-compose和co模块看了下,只能说自己终于有了一个比较浅显的认识了. 首先我们看下koa-compose的代码,就短短的十几行. function compose(middleware){ return function *(next){ var i = middleware.length; var prev = ne
两年前我遇到一个难题: https://q.cnblogs.com/q/78177 WebAPI中使用socket如果在server端回复了再返回值? 现在终于做出一种实现了: [HttpGet] public ApiActionResult OnceBackDemo() { var result = new ApiActionResult() { Success = false,
需要通过jquery传递到控制器方法的Model为: public class Person { public string Name { get; set; } public int Age { get; set; } } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-
最近使用jquery的ajax,发现有些效果不对,ajax请求后返回的json串回来了,但是执行顺序有问题. var isReload = false; $.post('/home/DetectCachedLoginInfor/', function (result) { if (result.errorMsg) { if (result.errorMsg) { alert(result.errorMsg); isReload = true; } } }, 'json'); if (isRelo
对于dispatch多个异步操作后的同步方法,以前只看过dispatch_group_async,看看这个方法的说明: * @discussion * Submits a block to a dispatch queue and associates the block with the given * dispatch group. The dispatch group may be used to wait for the completion * of the blocks it ref