我有一些在PHP中运行正常的代码.从postgres CLI我发出一个
NOTIFY job;
Run Code Online (Sandbox Code Playgroud)
Postgres正确引发了通知(我可以在PHP客户端中看到它),但无法在节点中读取它.
JS:
var pg = require('pg');
var conString = "your postgres information";
var client = new pg.Client(conString);
client.connect();
client.query('LISTEN job');
client.on('notification', function(msg) {
console.log('data');
});
Run Code Online (Sandbox Code Playgroud)
我宁愿保持简单.就是让像Postgres的一个过程的唯一途径这个?
我正在尝试使用 UIViewRepresentable 实现延迟加载 MyLazyHStack 视图,但它不会延迟加载元素。我在 MyLazyHStack 的内容中使用 LazyHStack,但所有元素都是立即加载,而不是根据需要延迟加载。这是我的代码的一个最小示例。有人可以帮我弄清楚我做错了什么吗?
struct MyLazyHStack<Content: View>: UIViewRepresentable {
var content: Content
func makeUIView(context: Context) -> UIView {
let scrollView = UIScrollView()
scrollView.isPagingEnabled = true
let hostingController = UIHostingController(rootView: content)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
scrollView.addSubview(hostingController.view)
NSLayoutConstraint.activate([
hostingController.view.leadingAnchor.constraint(equalTo: scrollView.leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: scrollView.trailingAnchor),
hostingController.view.topAnchor.constraint(equalTo: scrollView.topAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: scrollView.bottomAnchor),
hostingController.view.heightAnchor.constraint(equalTo: scrollView.heightAnchor)
])
return scrollView
}
func updateUIView(_ uiView: UIView, context: Context) {}
}
struct ContentView: View {
var body: some View {
MyLazyHStack {
LazyHStack {
ForEach(1..<100) { index in
Text("Element \(index)") …Run Code Online (Sandbox Code Playgroud)