出于学习目的,我正在创建一个 Node 应用程序,该应用程序需要从一个数组中获取 x 个 RxJS observables 并组合成一个事件流。我想知道事件何时以任何可观察的方式发生,以任何顺序(不是以任何顺序或完全完成)。我觉得它应该在一个合并的事件流中。基本上,来自任何可观察对象的第一个事件将完成。
为此,我觉得 merge() 可以解决问题。由于merge 不直接将数组作为参数,因此到目前为止我使用reduce 来帮助合并。
然而,最终的结果不是一个可观察的,而是一个函数。我也订阅不了 代码的简化版本可以在下面看到。
我怎样才能改变这个 Node 10.14.2, RxJS 6.4.x 代码来返回一个 observable 而不是我可以添加 .subscribe() 的“[function]”?
const { Observable } = require('rxjs');
const { merge } = require('rxjs/operators');
const observables = [
Observable.create(observer => observer.next('Hello')),
Observable.create(observer => observer.next('Hello')),
Observable.create(observer => observer.next('Hello'))
];
const mergedObservables = observables.reduce((merged, observable) => {
console.log(observable);
return merge(merged, observable);
});
// outputs:
// Observable { _isScalar: false, _subscribe: [Function] }
// Observable { _isScalar: false, _subscribe: [Function] …
Run Code Online (Sandbox Code Playgroud) 我正在通过开发自定义表单小部件模块迈出第一步,以了解Drupal 8的工作原理。我的目标是显示参考节点的图像字段值,而不是在单选按钮列表(在核心中可用)中显示其节点标题。这将使网站管理员在为节点选择背景图像时选择图片而不是文本。
这是使用Drupal 8内置的“复选框/单选按钮”小部件而无需自定义工作的表单的外观:
这是我希望我的自定义小部件出现(至少开始)的Photoshop样机:
到目前为止,我已经能够创建一个扩展“复选框/单选按钮”小部件的启动模块,并参考“ 开发人员示例”模块和遍历核心。这至少帮助我更好地了解了Drupal 8的模块结构。
模块结构:
modules
custom
back_image_widget
back_image_widget.info.yml
back_image_widget.module
src
Plugin
Field
Field Widget
BackImageWidget.php
Run Code Online (Sandbox Code Playgroud)
back_image_widget.info.yml:
name: Background Image Entity Widget
type: module
description: Used to list Background Image entities as images instead of text labels in the Text Message content type form.
package: Custom
core: 8.x
Run Code Online (Sandbox Code Playgroud)
back_image_widget.module:
<?php
/**
* @file
* Used to list Background Image entities as images instead of text labels in the Text Message content type form.
*/
Run Code Online (Sandbox Code Playgroud)
BackImageWidget.php: …
在通过 Dockerfile.template 文件部署到 docker 时,我有一个可行的解决方案来构建一个 TypeScript 节点应用程序:
# Thanks: https://github.com/balenalabs/multicontainer-getting-started
FROM balenalib/%%BALENA_MACHINE_NAME%%-node
# Defines our working directory in container
WORKDIR /usr/src/app
# Install packages
RUN install_packages build-essential libraspberrypi-bin
# Copies the package.json first for better cache on later pushes
COPY package.json package.json
# Install npm dependencies on the balena.io build server,
# making sure to clean up the artifacts it creates in order to reduce the image size.
#NOTE: I removed --production option because I need to run tsc after …
Run Code Online (Sandbox Code Playgroud) 按照此处的AWS 示例并引用balena.io 示例,我试图获取一个“事物”(当前是我 Mac 上的脚本)来更新 AWS 上的事物影子。
我越来越近了。到目前为止,我可以成功注册对事物影子的兴趣(更新:并订阅和发布到 MQTT 主题,接收更新)。但是,尝试更新阴影时出现超时。最初,由于事物证书上的政策缺失,我在注册兴趣时遇到了超时,现在是一个基本到位的政策。我目前的想法是,也许我需要使用不同的根 CA 证书(目前使用提供的 CA1),或者我的 base64 编码证书字符串有问题,编码为:
openssl base64 -in some-cert.pem -out some-cert.txt
#gets copied to clipboard and pasted in UI env field
pbcopy < some-cert.txt
Run Code Online (Sandbox Code Playgroud)
这是我到目前为止所拥有的。请注意 TODO 说明,因为这是一项正在进行的工作。
政策(目前过于宽松):
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "iot:*",
"Resource": "*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
故障排除.ts
// application endpoint
const AWS_ENDPOINT = "my-endpoint.iot.us-east-1.amazonaws.com";
// thing private key encoded in base64
const AWS_PRIVATE_CERT = "gets set in …
Run Code Online (Sandbox Code Playgroud) 作为 Amazon RDS 的新手,我正在寻找提供缓存 SELECT 查询的方法,以增强查询繁重的网站的性能(以及引起人们对 RDS 兴趣的其他功能)。到目前为止,我已经能够设置 Amazon Aurora 数据库,通过 MySQLWorkbench 将旧的 MySQL 数据库迁移到该数据库,并成功运行该网站的测试版本。该网站正在远程连接到 Aurora,在 AWS 外部运行。
我读到可以使用查询来增加 MySQL 查询缓存,例如(本例中为 16MB):
SET GLOBAL query_cache_size = 16777216
Run Code Online (Sandbox Code Playgroud)
这需要比可以远程连接的数据库用户更高的权限。主用户似乎设置为本地主机访问。如果这是正确的路线,我如何获得通过查询进行编辑的访问权限?
看起来我也可以编辑选项组。如果这是允许的路线,我猜我将需要设置特定选项或添加选项(没有看到默认选项组的添加选项)。
database caching amazon-web-services amazon-rds amazon-aurora
node.js ×3
amazon-rds ×1
aws-iot ×1
aws-policies ×1
caching ×1
database ×1
docker ×1
dockerfile ×1
drupal ×1
drupal-8 ×1
module ×1
npm ×1
php ×1
rxjs ×1
rxjs6 ×1
typescript ×1
widget ×1