小编fas*_*.de的帖子

如何在打字稿中使用rxjs6分区?

当我尝试partition在打字稿中使用rxjs6时,会抛出类型错配.此外,官方文档中的示例抛出了该错误.我想我必须投一些东西,但我不知道是什么.有什么建议?

import {fromEvent} from 'rxjs';
import {partition} from 'rxjs/operators';

document.body.innerHTML = "<DIV width=100 height=100></DIV>"


//Example Code from https://rxjs-dev.firebaseapp.com/api/operators/partition
const clicks = fromEvent(document, 'click');
const parts = clicks.pipe(partition(ev => ev.target.tagName === 'DIV'));
const clicksOnDivs = parts[0];
const clicksElsewhere = parts[1];
clicksOnDivs.subscribe(x => console.log('DIV clicked: ', x));
clicksElsewhere.subscribe(x => console.log('Other clicked: ', x)); 
Run Code Online (Sandbox Code Playgroud)

错误:

类型'UnaryFunction,[Observable,Observable]>'的参数不能分配给'OperatorFunction'类型的参数.类型'[Observable,Observable]'不能分配给'Observable'类型.类型'[Observable,Observable]'中缺少属性'_isScalar'.

请参阅https://stackblitz.com/edit/typescript-fdqhws

rxjs typescript rxjs6

6
推荐指数
1
解决办法
1540
查看次数

如何在项目之间共享打字稿类型?

我有两个项目(客户端和服务器)应该共享相同的定义。为此,我.d.ts在一个额外的npm包中外包了我的定义(),该包通过链接回两个项目npm link。两个主要项目无法识别新npm包中的类型。我想package.jsontypes)设置和一些设置tsconfig.jsontypestypeRoot)的各种组合,但我没有得到正确的。

我必须在定义包和主要包中设置什么才能使它正常工作?

typescript typescript-types

5
推荐指数
1
解决办法
1459
查看次数

如何在 html5 aria-label 中部分使用另一种语言?

屏幕阅读器的重音由<html lang="[language]">元素控制。当 lang 属性设置为 "de" 时,一些英语单词如 "email" 发音为 "Emil"(德语名字)。有没有办法将 aria-label 中单个单词的重音切换为另一种语言或其他众所周知的解决方法来实现这一点?

就像是

<button aria-label="(lang=en:E-Mail) schreiben">
Run Code Online (Sandbox Code Playgroud)

html wai-aria

3
推荐指数
1
解决办法
1626
查看次数

Meteor.methods:从内部回调将数据返回给客户端

我尝试通过Meteor服务器从LDAP服务器获取数据到客户端.但是LDAP-Request是异步的,并且该方法返回false,而不是在ldap.search函数调用中收集的结果.那么,当数据准备就绪时,如何同步调用ldap或在客户端触发事件?

  //defined on serverside
  Meteor.methods({
    searchPerson: function(account){
      var data = null;
      var LDAP = Npm.require('LDAP');
      var ldap = new LDAP({uri: 'ldaps://ldap-server', version: 3});

      var search_options = { 
        base: 'ou=xxx,dc=yyy,dc=zzz',
        scope: '1',
        filter: '(uid='+account+')',
        attrs: 'surname, givenname, mail'
      };  
      var bind_options = { 
        binddn:   'cn=aaa,ou=bbb,dc=ccc,dc=ddd', 
        password: 'password'
      };  

      ldap.open(function(err) {
        if (err) {
          throw new Meteor.Error('Can not connect');
        }   
        ldap.simpleBind(bind_options, function(err){
          if (err){
            throw new Meteor.Error('Can not bind');
          }   
          ldap.search(search_options, function(err, data){
            if (err){
              throw new Meteor.Error('Error occured');
            }   
            return data; …
Run Code Online (Sandbox Code Playgroud)

javascript asynchronous meteor

0
推荐指数
1
解决办法
1534
查看次数