从Facebook React Native Text Input文档中,我可以看出onSubmitEditing
使用时会发生以下情况:
按下文本输入的“提交”按钮时调用的回调。
但是,没有任何东西onChangeText
。我假设文本已更改,那么它将触发。
我为什么要彼此使用?例如,如果我要在TextInput
字段中输入一些文字,那我不是只想使用onChangeText
吗?在某些示例中,我看到了它们的使用,onSubmitEditing
而我对为什么要在一个之上使用另一个感到困惑。这个问题是不是想知道如何使提交按钮的不同-我问为什么我会用onChangeText
对比onSubmitEditing
。
我有一个 Kafka 流,它从一个主题中获取数据,并且需要将该信息过滤到两个不同的主题。
KStream<String, Model> stream = builder.stream(Serdes.String(), specificAvroSerde, "not-filtered-topic");
stream.filter((key, value) -> new Processor().test(key, value)).to(Serdes.String(), specificAvroSerde, "good-topic");
stream.filterNot((key, value) -> new Processor().test(key, value)).to(Serdes.String(), specificAvroSerde, "bad-topic");
Run Code Online (Sandbox Code Playgroud)
但是,当我这样做时,它会从主题中读取数据两次——不确定随着数据变大,这是否对性能有任何影响。有没有办法只过滤一次并将其推送到两个主题?
我正在尝试使用 Facebook React Native 教程构建一个新的 React Native 项目。此命令以前对我有用,但突然间我收到此错误消息。
(node:14866) UnhandledPromiseRejectionWarning: Error: Cannot find module '/MyProject/node_modules/react-native-scripts/build/scripts/init.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at _callee2$ (/.config/yarn/global/node_modules/create-react-native-app/build/index.js:128:32)
at tryCatch (/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:62:40)
at Generator.invoke [as _invoke] (/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:296:22)
at Generator.prototype.(anonymous function) [as next] (/.config/yarn/global/node_modules/regenerator-runtime/runtime.js:114:21)
at step (/.config/yarn/global/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
at /.config/yarn/global/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
(node:14866) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). …
Run Code Online (Sandbox Code Playgroud) 我一直在研究一些有关如何制作Discord Python Bot的示例,并且已经看到client
并且bot
几乎可以互换使用,而我找不到要在何时使用哪个。
例如:
client = discord.Client()
@client.event
async def on_message(message):
# we do not want the bot to reply to itself
if message.author == client.user:
return
if message.content.startswith('$guess'):
await client.send_message(message.channel, 'Guess a number between 1 to 10')
def guess_check(m):
return m.content.isdigit()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run('token')
Run Code Online (Sandbox Code Playgroud)
与
bot = commands.Bot(command_prefix='?', description=description)
@bot.event
async def on_ready():
print('Logged in as')
print(bot.user.name)
print(bot.user.id)
print('------')
@bot.command()
async def add(left : int, right : …
Run Code Online (Sandbox Code Playgroud) 我是 Jest 的新手,我正在尝试测试我的辅助功能。我目前没有使用任何 Typescript。
这是我运行时遇到的错误npm run test
:
TypeError: Cannot destructure property 'print' of '_graphql.default' as it is undefined.
助手.test.js:
import getDuplicateError from '../../helpers/auth'
test('Check if email already exists', () => {
error = "duplicate_email_key";
expect(getDuplicateError(error)).toBe(true);
})
Run Code Online (Sandbox Code Playgroud)
auth.js:
import graphql from "graphql";
const { print } = graphql;
export const getDuplicateError = (errors) => {
/*...*/ // Actual implementation doesn't use print
};
Run Code Online (Sandbox Code Playgroud)
笑话配置.js
export default {
preset: 'ts-jest/presets/js-with-babel',
testEnvironment: "node",
transform: {
"^.+\\.(js|jsx)?$": "babel-jest",
'^.+\\.(ts|tsx)?$': 'ts-jest', …
Run Code Online (Sandbox Code Playgroud) javascript ×2
node.js ×2
react-native ×2
reactjs ×2
apache-kafka ×1
discord ×1
discord.py ×1
java ×1
jestjs ×1
python ×1