在调用Web服务之前,我的服务类需要获取dataForUpdate
从我的状态调用的属性.目前,我这样做:
constructor ( public _store: Store<AppState>,
public _APIService:APIService) {
const store$ = this._store.select ('StateReducer');
.../...
let update = this.actions$.filter ( action => action.type==UPDATE )
.do( (action) => this._store.dispatch({type: REDUCER_UPDATING, payload : action.payload }) )
*** GET STATE ***==> .mergeMap ( action => store$.map ( (state : AppState)=> state.dataForUpdate ).distinctUntilChanged(),
(action, dataForUpdate) {
return { type:action.type, payload : {employee:action.payload, dataForUpdate :dataForUpdate } };
})
* AND CALL API *==> .mergeMap ( action =>this._APIService.updateEmployee(action.payload.employee, action.payload.dataForUpdate),
(action, APIResult) => { return …
Run Code Online (Sandbox Code Playgroud) 我创建了AngularJS 2服务,并在2个不同的组件中使用它:App-Component&Sub-Component.每个输出属性'log'(一个字符串)我的服务.
StateService类:
@Injectable ()
class StateService {
public log : string;
static count : number = 0;
constructor () {
this.log = '';
StateService.count++;
this.writeToLog ('CREATED '+StateService.count+' at ' + new Date().toString());
}
public writeToLog (text : string) : void {
this.log += text + '\n';
}
}
Run Code Online (Sandbox Code Playgroud)
零件 :
@Component ({
selector : 'Sub-Component',
template : `<hr>
This is the Sub-Component !
<BR>
StateService Log :
<pre>{{ _stateService.log }}</pre>
<button (click)="WriteToLog ()">Write to log</button>
`,
providers : [StateService] …
Run Code Online (Sandbox Code Playgroud) 在JsBin中,我在Firefox和Chrome中收到错误"Rx.Observable.just不是函数".JsBin示例:http://jsbin.com/vunuta/edit?html,js,console
HTML:
script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.7/dist/global/Rx.umd.js">
Run Code Online (Sandbox Code Playgroud)
打字稿:
Rx.Observable.from ([1,2,3]).subscribe(x => console.log(x)); // Work
Rx.Observable.just (99).subscribe(x => console.log(x)); // Fail
Rx.Observable.return (99).subscribe(x => console.log(x)); // Fail
Run Code Online (Sandbox Code Playgroud)
TX
我是AWS世界的新手.我在RDS(US-East-1a)上访问我的Microsoft SQL Server 2012 Express(11.00.5058)实例时遇到问题.
当我创建数据库实例时,我能够访问它,创建一些表,传输数据等等.一切正常!
我没有更改任何内容,并且在一些不活动后几个小时,我尝试使用Microsoft SQL Server企业管理器访问SQL Server实例,但我无法再连接到它.我得到以下消息:
无法连接到m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com,1433.
建立与SQL Server的连接时发生与网络相关或特定于实例的错误.服务器未找到或无法访问.验证实例名称是否正确,以及SQL Server是否配置为允许远程连接.(提供程序:TCP提供程序,错误:0 - 等待操作超时.)(Microsoft SQL Server,错误:258)
目前,实例显示为可用,安全组为'rds-launch-wizard(sg-be4afcc6)'.
我试图通过Telnet连接到1433端口,但没有成功.
实例名称为m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com.
你知道附加什么吗?
非常感谢你的帮助.
更新
Telnet命令返回:
telnet m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com 1433
Connecting To m3instance.cqbvdcpcgye3.us-east-1.rds.amazonaws.com...
Could not open connection to the host, on port 1433: Connect failed
Run Code Online (Sandbox Code Playgroud)
数据库设置:
安全组:
VPC:
我试图通过使用我的家庭连接或咖啡店wifi连接没有成功.我现在没有检查我的IP地址是什么,但奇怪的是,当我创建数据库实例(创建SQL表,传输数据等等)时,我能够连接到SQL服务器,但几个小时后(并且没有任何变化),我无法访问它.
可能如果我在这样的安全组/入站规则中添加新规则,它将解决我的问题:(我没有尝试,因为我现在正在工作,我们有阻止SQL访问的防火墙)
此时,数据不敏感,安全性不是大问题.
再次感谢您的帮助!
花一些时间试图弄清楚为什么我的plunker不工作:(
https://plnkr.co/edit/JHODQeWQtYmz4UkYzFds?p=preview
错误附加在以下行
let load = this.actions$.filter (action => return action.type==START_LOADING);
Run Code Online (Sandbox Code Playgroud)
actions $定义如下:
private actions$ : BehaviorSubject<Action> = new BehaviorSubject<Action>({type: null, payload: null});
Run Code Online (Sandbox Code Playgroud)
我导入了这个
import { Subject } from "rxjs/subject";
import { Observable } from "rxjs/Observable";
import { BehaviorSubject } from 'rxjs/subject/BehaviorSubject';
Run Code Online (Sandbox Code Playgroud)
在Chrome的调试器中,我看到一些功能可用(地图,电梯,扫描等)但不过滤.
有人知道为什么过滤器在BehaviorSubject上不可用?我想这是一个简单的错误,但我找不到;)