小编Jer*_*yow的帖子

观察对象数组的属性是否有任何更改

我正在使用Aurelia,我有一个绑定到网格的项目数组,并且它们上面有一个选定的属性.我想绑定一个按钮,当任何一个项为真时启用.我可以做一个蛮力的方法,我有一个过滤列表并返回所选项目的getter,但这意味着我将在应用程序中不断进行脏检查,我不想这样做.我希望有一个更有效的方法.有任何想法吗?

javascript aurelia aurelia-binding

16
推荐指数
1
解决办法
6432
查看次数

Aurelia中fetch()的错误处理

我有一个API,其中包含服务器引发错误时出错的有用描述(状态= 500).该描述作为响应文本的一部分.我的客户端代码,使用Aurelia,通过aurelia-fetch-client使用通用方法调用api 来进行调用:

function callRemoteService(apiName, timeout) {
  return Promise.race([
    this.http.fetch(apiName),
    this.waitForServer(timeout || 5000)  // throws after x ms
  ])
    .then(response => response.json() )
    .catch(err => {
        if (err instanceof Response) {
          // HERE'S THE PROBLEM.....
          err.text().then(text => {
            console.log('Error text from callRemoteService() error handler: ' + text);
            throw new Error(text)
          });
        } else if (err instanceof Error) {
          throw new Error(err.message);
        } else {
          throw new Error('Unknown error encountered from callRemoteService()');
        }
    });
}
Run Code Online (Sandbox Code Playgroud)

请注意,我想以一致的方式捕获服务器(获取或超时)错误,然后throw只返回一个简单的错误消息到调用视图.我可以callRemoteService …

javascript fetch aurelia aurelia-fetch-client

16
推荐指数
1
解决办法
5246
查看次数

在Aurelia辅助注射?

我有一个类,其构造函数有两个参数; 一个是依赖项,另一个是配置属性:

@inject(Dependency)
class MyClass{
  constructor(dependency, config){
  }
}
Run Code Online (Sandbox Code Playgroud)

如何利用Aurelia的依赖注入来自动注入依赖项,但允许类的使用者指定配置值?

javascript dependency-injection aurelia

14
推荐指数
2
解决办法
2863
查看次数

你如何替代Aurelia的HttpClient?

我是Aurelia的新手.

您将如何更改以下代码以提供虚拟HttpClient,例如json reader,它只提供一组静态的json数据,从而无需开发中的服务器.

import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-fetch-client';

@inject(HttpClient)
export class Users {
  heading = 'Github Users';
  users = [];

  constructor(http) {
    http.configure(config => {
      config
        .useStandardConfiguration()
        .withBaseUrl('https://api.github.com/');
    });

    this.http = http;
  }

  activate() {
    return this.http.fetch('users')
      .then(response => response.json())
      .then(users => this.users = users);
  }
}
Run Code Online (Sandbox Code Playgroud)

javascript json aurelia

14
推荐指数
1
解决办法
4198
查看次数

为什么SQL Server突然决定使用如此糟糕的执行计划?

背景

我们最近遇到了sql server在我们的一个较大的表(大约175,000,000行)上使用的查询计划的问题.该表的列和索引结构未发生5年以上的变化.

表和索引如下所示:

create table responses (
    response_uuid uniqueidentifier not null,
    session_uuid uniqueidentifier not null,
    create_datetime datetime not null,
    create_user_uuid uniqueidentifier not null,
    update_datetime datetime not null,
    update_user_uuid uniqueidentifier not null,
    question_id int not null,
    response_data varchar(4096) null,
    question_type_id varchar(3) not null,
    question_length tinyint null,
    constraint pk_responses primary key clustered (response_uuid),
    constraint idx_responses__session_uuid__question_id unique nonclustered (session_uuid asc, question_id asc) with (fillfactor=80),
    constraint fk_responses_sessions__session_uuid foreign key(session_uuid) references dbo.sessions (session_uuid),
    constraint fk_responses_users__create_user_uuid foreign key(create_user_uuid) references dbo.users (user_uuid),
    constraint fk_responses_users__update_user_uuid foreign key(update_user_uuid) …
Run Code Online (Sandbox Code Playgroud)

sql sql-server performance

13
推荐指数
1
解决办法
7288
查看次数

Aurelia中的数组订阅

假设我有一系列元素,除了在我的应用程序中显示列表外,我想将列表同步到服务器HttpClient.如何观察阵列的变化?我试过了:

@inject(ObserverLocator)
export class ViewModel {

    constructor(obsLoc) {
        this.list = [];
        obsLoc.getObserver(this, 'list');
            .subscribe(li => console.log(li));
    }
}
Run Code Online (Sandbox Code Playgroud)

但我既没有错误也没有记录消息.

javascript aurelia aurelia-binding

13
推荐指数
1
解决办法
4529
查看次数

GitHub如何检测浏览器是否支持彩色表情符号?

当使用没有颜色表情符号支持的浏览器访问GitHub时,它会将表情符号字形作为图像文件加载.

GitHub没有颜色表情符号支持

但是当使用支持彩色表情符号的浏览器访问GitHub时,它会让浏览器正常渲染字形.

GitHub支持彩色表情符号

GitHub如何知道浏览器是否支持彩色表情符号?

html5 github emoji

13
推荐指数
1
解决办法
812
查看次数

aurelia-fetch-client.d.ts未定义的符号

当我在项目中包含aurelia-fetch-client时,我遇到了一些我无法解决的错误.它说它无法找到:Request,Response,Headers,BufferSource,URLSearchParams,如下图所示:

在此输入图像描述

我怎么解决这个问题?

javascript aurelia

12
推荐指数
2
解决办法
775
查看次数

使用Aurelia高效渲染大型数据表

使用Aurelia渲染大型数据表时,我正在努力提高性能.

即使在中等大小的表(20x20)的情况下,我的Chrome也不会低于200ms,MS Edge需要大约800ms而IE11大约需要2s.如果要添加(虚拟)滚动,200ms也是一个问题.处理时间随着每个表格单元的绑定数量而增加.我已经整理了一个(例子)绑定'css','class',当然还有单元格内容.

<table class="table">
  <tbody>
    <tr repeat.for="row of rows">
      <td repeat.for="column of columns" css.bind="getCellStyle(column, $parent.$first)" class.bind="getCellClasses(column, row)">
        <template replaceable part="cell-template">
          <span>${getCellText(column, row)}</span>
        </template>
      </td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我有什么想法可以提高性能?

基于初始提议,我试图避免嵌套重复,但在我的情况下这是不可能的,因为列和行都是动态的.

javascript performance aurelia

12
推荐指数
1
解决办法
2166
查看次数

如何强制在Aurelia中重新评估或重新渲染绑定

我开始使用Aurelia,RethinkDB和Socket.IO的简单TODO应用程序.我似乎在重新渲染或重新评估通过Socket.IO更改的对象时遇到问题.所以基本上,一切都在第一个浏览器上运行良好但在第二个浏览器中没有重新渲染,而在控制台中显示对象确实显示了我的对象的差异.问题仅在于更新对象时,它完全适用于从待办事项数组创建/删除对象.

HTML

<ul>
    <li repeat.for="item of items">
      <div show.bind="!item.isEditing">
        <input type="checkbox" checked.two-way="item.completed" click.delegate="toggleComplete(item)" />
        <label class="${item.completed ? 'done': ''} ${item.archived ? 'archived' : ''}" click.delegate="$parent.editBegin(item)">
          ${item.title}
        </label>
        <a href="#" click.delegate="$parent.deleteItem(item, $event)"><i class="glyphicon glyphicon-trash"></i></a>
      </div>
      <div show.bind="item.isEditing">
        <form submit.delegate="$parent.editEnd(item)">
          <input type="text" value.bind="item.title" blur.delegate="$parent.editEnd(item)" />
        </form>
      </div>
    </li>
  </ul>
Run Code Online (Sandbox Code Playgroud)

带有RethinkDB更改源的NodeJS

// attach a RethinkDB changefeeds to watch any changes
r.table(config.table)
    .changes()
    .run()
    .then(function(cursor) {
        //cursor.each(console.log);
      cursor.each(function(err, item) {
        if (!!item && !!item.new_val && item.old_val == null) {
          io.sockets.emit("todo_create", item.new_val);
        }else if (!!item …
Run Code Online (Sandbox Code Playgroud)

javascript sockets rethinkdb aurelia aurelia-binding

12
推荐指数
1
解决办法
4059
查看次数