我正在创建一个随机的实时聊天,比如"聊天".
我无法使用等待列表在私有线程中连接两个随机用户.使用Laravel Broadcasting和Laravel Job最好的方法是什么?
例如:
Route::get('/start', function () {
// add me to the wait list
// wait for another person
// find another person
// remove me and another person from the wait list
// dispatch event
App\Events\AnotherPersonFound::dispatch($anotherPerson, $threadId);
});
Run Code Online (Sandbox Code Playgroud) 例如,我将使用一个接收参数并返回一个始终返回数字的函数。我会得到两种可能的结果:
如果我转换第一个块中的参数,返回类型将丢失
// foo(bar: string | number) => () => string | number
function foo(bar: string | number) {
bar = +bar;
return function () {
return bar;
}
}
Run Code Online (Sandbox Code Playgroud)如果我转换第二个块中的参数,将正确推断返回类型:
// foo2(bar2: string | number) => () => number
function foo2(bar2: string | number) {
return function () {
return +bar2;
}
}
Run Code Online (Sandbox Code Playgroud)为什么重定义的参数类型会丢失?
在RDBMS中,我相信有几种方法可以设计表之间的关系.所以,我想问问有什么优点和缺点创造之间的关系与关联表和无关联表.是否有正式的解决方案来决定两者?
使用通用表,下面我演示了我的意思:
示例#1(没有关联表)
用户
+----+-------+
| id | name |
+----+-------+
| 1 | John |
| 2 | James |
| 3 | Jacob |
+----+-------+
Run Code Online (Sandbox Code Playgroud)
评论
+----+-----------------------------+---------+
| id | text | user_id |
+----+-----------------------------+---------+
| 1 | Lorem ipsum dolor sit amet. | 1 |
| 2 | Praesent ultricies libero. | 2 |
| 3 | Donec eget blandit nunc. | 3 |
+----+-----------------------------+---------+
Run Code Online (Sandbox Code Playgroud)
注意:对评论作者的引用存储在comments.
示例#2(带关联表) …
我读过 React Native 支持 Typescript 而没有像react-native- typescript -transformer这样的依赖项。如何使用Typescript将其配置为编码?