Node.js Alexa任务问题
我目前正在通过AWS Lambda编写Node.js Alexa任务,我一直在尝试编写一个函数,该函数从OpenWeather API接收信息并将其解析为一个名为的变量weather
.相关代码如下:
var request = require('request');
var weather = "";
function isBadWeather(location) {
var endpoint = "http://api.openweathermap.org/data/2.5/weather?q=" + location + "&APPID=205283d9c9211b776d3580d5de5d6338";
var body = "";
request(endpoint, function (error, response, body) {
if (!error && response.statusCode == 200) {
body = JSON.parse(body);
weather = body.weather[0].id;
}
});
}
function testWeather()
{
setTimeout(function() {
if (weather >= 200 && weather < 800)
weather = true;
else
weather = false;
console.log(weather);
generateResponse(buildSpeechletResponse(weather, true), {});
}, 500);
} …
Run Code Online (Sandbox Code Playgroud) 所以我试图在Firebase和Heroku上构建和部署我的Angular 4应用程序,但是我遇到了如下错误:
/ Users/.../...中的错误(57,49):属性'firebase'在类型'{production:boolean; }".
它发生在我运行时ng build --prod
,我的部署服务器工作正常.这是我的app.module.ts文件,供参考:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { Ng2ScrollimateModule } from 'ng2-scrollimate';
import { Ng2PageScrollModule } from 'ng2-page-scroll';
import { HttpModule } from '@angular/http';
import {
trigger,
state,
style,
animate,
transition,
keyframes
} from '@angular/animations';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { environment …
Run Code Online (Sandbox Code Playgroud) heroku environment-variables firebase firebase-hosting angular
我正在 React Native 中开发一个热图组件,它本质上是一个<View>
响应pointerEvents
用户提供的组件。它们children
从视图中提取this.props
并传递到视图中。
<View
style={s.overlay}
onLayout={this._onLayout}
onMagicTap={this._onDoubleTwoFingerTouch}
onAccessibilityTap={this._onDoubleTouchAccessible}
onStartShouldSetResponder={this._onTouchStart}
onResponderMove={this._onTouchMove}
onResponderReject={this._onTouchCancel}
onResponderTerminate={this._onTouchCancel}
onResponderRelease={this._onTouchEnd}
pointerEvents={'auto'}
>
{children}
</View>
Run Code Online (Sandbox Code Playgroud)
只要视图下方没有可触摸组件(如<TouchableOpacity>
组件),该视图就会接收所有触摸事件。显然,子组件响应pointerEvents
.
我已经知道auto
、box-none
等pointerEvents
枚举如何运作,但我还没有找到正确的组合或技巧来将这些事件从父母传递给孩子。
我如何pointerEvents
在用户按下的父组件和子组件中做出响应?
对于社交媒体应用,我有一组使用其ID引用的Feed对象AngularFire 2
.一旦这些ID中的每一个都从存储实际feed对象的数据库中提取了相关数据,我希望feedCards
用这些信息更新Observable对象,这样我就可以在HTML中异步显示一个feed对象集合.这是一个非常混乱的事件链,所以让我总结一下.
循序渐进的方法
displayFeed()
在NavController
加载页面feed
上的组件之前调用Main
.displayFeed()
获取twiner
项目,该项目本质上是用户配置文件项目,然后将用户配置文件存储在userProfile
变量中.feedCards
Observable设置为等于loadFeed()
,返回Observable数组.loadFeed()
使用全局对象的id
值userProfile
来加载存储在用户配置文件中的订阅源引用列表.feed
变量设置为等于源引用的结果列表.loadFeed
返回一个Observable对象,其中feed
引用列表由每个feed引用包含的数据映射.pullFeedData(number)
接受对feed对象的引用并返回带有关联的feed数据的observable.什么有用
alert(JSON.stringify(feedData));
提醒正确的feed
对象
其他一切.
什么行不通
feed.map(...
不会更新feed数组,因为pullFeedData(number)
pulls并feedData
异步返回.因此,alert(JSON.stringify(data));
在displayFeed()
警报中[null]
.码
feed.ts
userProfile:any;
feed: FirebaseListObservable<any>;
feedData: FirebaseObjectObservable<any>;
feedCards: Observable<any[]>;
constructor(public db: AngularFireDatabase, public nativeStorage: NativeStorage) {}
displayFeed():void {
this.nativeStorage.getItem('twiner').then((res) => …
Run Code Online (Sandbox Code Playgroud) firebase ×2
javascript ×2
angular ×1
asynchronous ×1
aws-lambda ×1
dom-events ×1
heroku ×1
ionic2 ×1
ionic3 ×1
node.js ×1
react-native ×1
reactjs ×1
request ×1