问题标签 [frp]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
java - Java中可变模型的声明性派生属性
是否有用于同步 POJO 属性的框架?例如,我想表达(以某种高级的、声明性的形式),foo.text = bar.text + baz.text
或者foo.y = (max(bars, y)).y
不必注册属性更改,元素添加和删除值和(尤其是)集合上的侦听器,这些是重复且容易出错的。
haskell - 带有箭头语法的 Haskell/Yampa 中的简单 putStrLn
我将 Haskell 与使用箭头语言扩展的 Yampa FRP 库一起使用。
我怎样才能在 SF 中做一个简单的 putStrLn?
箭头语法抱怨表达式不在箭头中(当然),但即使有箭头我也没有输出
f# - 功能反应式 F# - 在游戏中存储状态
我是一名学生,目前正在使用 F# 学习功能反应范式。这对我来说是全新的观点。昨天我学习了使用这种范例创建一个简单的乒乓球游戏。到目前为止,我掌握的想法是:我们认为价值是时间的函数。就其纯粹的形式而言,它是无国籍的。但是,我需要记住球(或状态)的位置。所以我总是将球的当前位置作为全局函数的参数传递。
如果我们谈论稍微复杂一点的游戏,比如 Space Invaders,我们有很多状态(外星人的位置、外星人当前的 HP、剩余的炸弹数量等)
有没有一种优雅/最好的方法来解决这个问题?我们总是将状态存储在顶层吗?是否应该将所有当前状态作为全局函数的附加输入参数给出?
任何人都可以使用 F# 上的简单示例来解释这一点吗?非常感谢。
haskell - 为什么这个 Yampa 弹球会陷入死循环?
我正在尝试使用 Yampa 框架模拟弹跳球:给定初始 x 位置、高度和速度,球应该根据重力规则弹跳。信号函数将“Tip-Event”作为输入,其想法是“当球被倾斜时,它的速度应该加倍”。
球弹得很好,但每次发生翻倒事件时,该函数都会进入无限循环。我想我可能需要添加一个延迟(dSwitch,pre,notYet?),但我不知道怎么做。任何帮助,将不胜感激!
编辑:我设法通过在发生小费时反馈一个标志来避免无限循环,但这仍然不是正确的做法......
haskell - FRP(反应式):如何使用 filterE?
我希望下一个将在一秒钟内打印 10 次“()”。但它在一秒钟后挂起。为什么?
我发现它与filterE中使用的liftM有关:
我尝试重新实现filterE
usingfmap
并且它似乎有效。为什么?该标准filterE
是如何设计使用的?
我发现自己重新实现了reactive
包提供的许多标准功能(例如diffE
,integrate
)。这是否意味着该软件包有问题或我以错误的方式使用它?
谢谢!
haskell - How to best synchronize game engine and network server in Haskell?
I am designing a little soccer game where the game engine (that computes player moves etc.) runs on a server, and rendering and keyboard/mouse handling is done by the client. For the server (Haskell) I want to use
- Happstack for client-server communication
- Yampa / Reactimate for the game engine
Every 20ms or so, the client should send keyboard and mouse events to the server via HTTP GET, receive the current game status (JSON-encoded ball and player positions) and render it. I am thinking about using SDL infrastructure for the game loop, input handling and rendering.
The server basically runs two threads: A happstack server receives the HTTP GET, puts the keyboard / mouse commands in a queue, reads the current game status from a second queue and answers the HTTP GET request.
The second thread runs a Yampa game engine, as described in the Yampa Arcade paper: The game engine computes the new round as quickly as possible (no ticks) and puts the result in the render queue.
General question: Does this look like a feasible architecture?
Specific question: How would one design the server side rendering queue: Would one use a Chan for this? If the game engine is quicker on average than the "ticking" on the client side, the queue will get longer and longer. How could this be handled with Chan?
Your comments are very welcome!
scala - Scala.React 的状态如何?
我刚刚阅读了 Deprecating the Observer Pattern并发现它非常吸引人。
文档中描述的 Scala.React 包的状态如何?我找到了一份 Scala.React 快照的 tarball,但似乎没有太多文档或主动维护。我还发现了 ScalaFX,它看起来可能与反应式编程有关,但同样没有维护。
是否有任何项目基于本文中的想法来创建基于响应式的 GUI 框架?
functional-programming - 功能响应式编程语言规范
我正在考虑在某个时候创建一个功能性反应框架。我已经阅读了很多关于它的内容并看到了一些示例,但我想清楚地了解这个框架必须做什么才能被视为 FRP 扩展/dsl。我并不真正关心实施问题或细节等,而是更关心在完美世界情况下需要什么。
理想的函数式反应式编程语言的关键操作和品质是什么?