我的角应用程序使用websocket与后端进行通信.
在我的测试用例中,我有2个客户端组件.Observable计时器按预期打印两个不同的客户端ID.
每个ngOnInit()还打印其客户端的id.
现在出于某种原因,对于每条消息,websocketService.observeClient()的订阅被调用2次,但this.client.id总是打印第二个客户端的值.
继承我的客户组件
@Component({
...
})
export class ClientComponent implements OnInit {
@Input() client: Client;
constructor(public websocketService: WebsocketService) {
Observable.timer(1000, 1000).subscribe(() => console.log(this.client.id));
}
ngOnInit() {
console.log(this.client.id);
this.websocketService.observeClient().subscribe(data => {
console.log('message', this.client.id);
});
}
}
Run Code Online (Sandbox Code Playgroud)
和我的websocket服务
@Injectable()
export class WebsocketService {
private observable: Observable<MessageEvent>;
private observer: Subject<Message>;
constructor() {
const socket = new WebSocket('ws://localhost:9091');
this.observable = Observable.create(
(observer: Observer<MessageEvent>) => {
socket.onmessage = observer.next.bind(observer);
socket.onerror = observer.error.bind(observer);
socket.onclose = observer.complete.bind(observer);
return socket.close.bind(socket);
}
);
this.observer = …Run Code Online (Sandbox Code Playgroud) 从这个例子中我在Angular2中有简单的TranslationModule .在一次angular-cli更新之后,我得到了上面提到的错误,但我不知道我必须在这里更改:
import {NgModule} from "@angular/core";
import {TranslatePipe} from "./translate.pipe";
import {TRANSLATION_PROVIDERS} from "./translations";
import {TranslateService} from "./translate.service";
@NgModule({
declarations: [
TranslatePipe
],
providers: [
TRANSLATION_PROVIDERS,
TranslateService
],
exports: [
TranslatePipe
]
})
export class TranslateModule {
}
Run Code Online (Sandbox Code Playgroud)
而翻译
import {OpaqueToken} from '@angular/core';
// import translations
import {LANG_EN_US_NAME, LANG_EN_US_TRANS} from './lang-en_US';
import {LANG_DE_DE_NAME, LANG_DE_DE_TRANS} from './lang-de_DE';
// translation token
export const TRANSLATIONS = new OpaqueToken('translations');
// default language
export const DEFAULT_LANG = "en_US";
// all translations
export const …Run Code Online (Sandbox Code Playgroud) 我想写以下内容if let但Ok(config)没有提供类型toml::from_str
let result: Result<Config, _> = toml::from_str(content.as_str());
match result {
Ok(config) => {}
_ => {}
}
// if let Ok(config) = toml::from_str(content.as_str()) {
//
// }
Run Code Online (Sandbox Code Playgroud)
我尝试过Ok(config: Config)但没有运气。无法推断成功类型。
我设置了一个 Kubernetes 集群,其中包含 1 个主节点 (kube-master) 和 2 个从节点(kube-node-01 和 kube-node-02)
一切都运行良好......现在在 debianstretch->buster 升级之后,我的 coredns podCrashLoopBackOff由于某种原因失败了。
我做了一个kubectl describe,错误是Readiness probe failed: HTTP probe failed with statuscode: 503
Readiness url 对我来说看起来很可疑http-get http://:8080/health delay=0s timeout=1s period=10s #success=1 #failure=3......没有主机名!?那是对的吗?
该Liveness属性也没有主机名。
所有虚拟机均可相互 ping 通。
有任何想法吗?
由于某种原因,我的 staticRules 没有被应用。
添加“org.grails.plugins:spring-security-core:3.0.0.M1”插件并执行
grails s2-quickstart com.testapp User Role
Run Code Online (Sandbox Code Playgroud)
成功创建了角色用户和用户角色域。还创建了一个带有一些设置的 application.groovy 文件。
但我正在使用 application.yml 文件来配置我的应用程序。所以我将属性移动到我的 application.yml 并删除了 .groovy 文件。
由于某种原因,未应用 staticRules。可能有语法错误。
---
grails:
plugin:
springsecurity:
userLookup:
userDomainClassName: 'User'
authorityJoinClassName: 'UserRole'
authority:
className: 'Role'
apf:
postOnly: false
password:
algorithm: 'bcrypt'
controllerAnnotations:
staticRules:
/: permitAll
/error: permitAll
/index: permitAll
/index.gsp: permitAll
/shutdown: permitAll
/assets/**: permitAll
/**/js/**: permitAll
/**/css/**: permitAll
/**/images/**: permitAll
/**/favicon.ico: permitAll
mime:
disable:
accept:
header:
userAgents:
...
Run Code Online (Sandbox Code Playgroud)
我尝试了多种变体,例如
'/': 'permitAll'
/: 'permitAll'
Run Code Online (Sandbox Code Playgroud)
但是每次打开 localhost:8080/ 都会提示我登录!
我有一个Angular2组件在表中显示一些数据.
export class DiagnosisComponent {
headers: Array<String> = ["hello world", "hello world"];
table: Observable<TableData>;
constructor(private eventService: EventService) {
this.table = this.eventService.getDiagnosisEvents();
this.table.subscribe(console.log.bind(console));
}
}
Run Code Online (Sandbox Code Playgroud)
这是TableData类
export class TableData {
content: Array<any>;
paging: Paging;
constructor(obj: any) {
this.paging = {
size: obj.size,
totalElements: obj.totalElements,
currentPage: 1
};
this.content = obj.content;
}
}
export interface Paging {
size: number;
totalElements: number;
currentPage: number;
}
Run Code Online (Sandbox Code Playgroud)
现在我想将table.content数组绑定到带有异步管道的*ngFor.我的问题是我需要获取嵌套数据,而不是TableData本身.
<div class="row">
<vpscout-filter></vpscout-filter>
<table class="table">
<thead>
<tr><th *ngFor="let header of headers">{{header | translate}}</th></tr>
</thead>
<tbody>
<tr *ngFor="let …Run Code Online (Sandbox Code Playgroud) 我有一个 Rx.Observable.webSocket 主题。我的服务器端点无法处理同时接收的消息(<25 毫秒)。现在我需要一种方法来扩展我的 websocket 主题的 next() 调用。
我创建了另一个主题requestSubject并订阅了这个。然后调用订阅中的下一个 websocket。
requestSubject.delay(1000).subscribe((request) => {
console.log(`SENDING: ${JSON.stringify(request)}`);
socketServer.next(JSON.stringify(request));
});
Run Code Online (Sandbox Code Playgroud)
使用延迟将每个下一个调用转移到相同的延迟时间,然后所有下一个调用在同一时间之后发出......这不是我想要的。
我试过delay,throttle,debounce但它并不适合。
以下应该说明我的问题
Stream 1 | ---1-------2-3-4-5---------6----
after some operation ...
Stream 2 | ---1-------2----3----4----5----6-
Run Code Online (Sandbox Code Playgroud) 我在PendingIntents上遇到了一些麻烦.每次我的应用程序打开时,它都会安排一些广播.我的问题是,现有的PendingIntents无法识别.
我知道必须使用相同的参数创建PendingIntents和unterlaying Intents.
她是我的代码......在我的Launcher活动中作为Asynctask开始.
long nextExecute = getNextExecute(t);
if (nextExecute > System.currentTimeMillis()) {
int tt = 12;
intent = new Intent(context, BirthExecutor.class);
intent.putExtra(Target.ROW_ID, tt);
PendingIntent pending = PendingIntent.getBroadcast(context, 10, intent, PendingIntent.FLAG_NO_CREATE);
if (pending != null) {
manager.set(AlarmManager.RTC_WAKEUP, nextExecute, pending);
BirthLog log = new BirthLog("Scheduled " + t.getFirstname() + " " + t.getLastname() + " on " + df.format(nextExecute));
log_helper.insertLog(log);
} else {
BirthLog log = new BirthLog(t.getFirstname() + " " + t.getLastname() + " already active!");
log_helper.insertLog(log);
}
intent = …Run Code Online (Sandbox Code Playgroud) android alarmmanager android-service android-pendingintent android-background
我有一个带有存储库的 Spring 应用程序
interface EventRepository extends JpaRepository<Event, Long>, QueryByExampleExecutor<Event> { }
Event e = new Event();
e.setTest('ABC');
eventRepository.findAll(Example.of(e), pageable);
Run Code Online (Sandbox Code Playgroud)
工作得很好,我快到了。但我需要限制在“从”和“到”之间的日期范围内
我看到一些帖子说它不适用于 QBE,但这是在 2015 年。
我创建了一个 Range 对象,但我不知道如何应用它。
我不能使用默认的弹簧方式
@Transactional
interface EventRepository extends JpaRepository<Event, Long>, QueryByExampleExecutor<Event> {
def findBetween(Date lower, Date upper)
}
Run Code Online (Sandbox Code Playgroud)
因为我有一堆动态搜索参数。
我有一个带点符号的键的地图,但我需要它作为嵌套地图.
[test.key.one: 'value1', text.key.two: 'value2']
Run Code Online (Sandbox Code Playgroud)
现在的结果应该是
[
test: [
key: [
one: 'value1',
two: 'value2'
]
]
]
Run Code Online (Sandbox Code Playgroud)
这是我对代码的想法
def extract(String key, String value) {
if(key.contains(".")) {
def (String target, String subKey) = key.split('\\.', 2)
return ["$target": extract(subKey, value)]
} else {
return ["$key": extractType(value)]
}
}
Run Code Online (Sandbox Code Playgroud)
但是我想知道是否有任何时髦的魔法在封闭中做这件事,或者在其他好东西的帮助下使其变得更简单.
我的应用程序在开发过程中工作正常,文件下载工作得很好.
现在在使用-production构建应用程序后,此代码sipped失败.它试图加载一些没有名字的"/.js"文件?!?
在我看来,我有这个 requires : ['Ext.form.FormPanel'],
打印日志消息,但表单提交失败c is not a constructir:(
onInvoiceDownloadButtonClicked : function(grid, rowIndex, colIndex, item, e, record) {
console.log('button pressed');
var fp = new Ext.form.FormPanel({
url : 'back/invoice/get/' + record.get('id'),
standardSubmit : true,
method : 'POST'
});
console.log(fp);
fp.form.submit();
}
Run Code Online (Sandbox Code Playgroud)
是的,有一个同步加载警告,但有.js?没有文件名嗯
angular ×3
rxjs ×2
alarmmanager ×1
android ×1
between ×1
coredns ×1
dictionary ×1
extjs6 ×1
grails-3.0 ×1
groovy ×1
javascript ×1
kubernetes ×1
observable ×1
pipe ×1
rust ×1
spring ×1