Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> When you rename or move a file that you're editing, its window instantly reflects the new name and location.

How does macOS achieve its reactivity? Is it two-way bindings? Events/messages? Immediate mode re-renders?



If I had to venture to guess based on how their APIs work, it's probably events. There's a system called "NotificationCenter" which can be observed to receive system events within Apple API's which is quite old.


Yes, there's the NSEvent ecosystem.

Cocoa also lets you two-way bind a state object with the view as long as the state object (whether it's a controller or a model or a view model) implements key-value coding; notably, the blessed data framework (Core Data) is KVC-compliant, so apps that use Core Data sort of get all this for free. Core Data also has fairly good support for undo/redo. That being said, Core Data is a fairly idiosyncratic relational data layer. It's sort of a double-edged sword: it's easy to do 90% of what you want, and the last 10% will involve some deep dives into Apple's documentation. But it's been a long time since I've written an app on OS X -- someone will have to correct my errors.

I've long thought that the inverse of what the OP suggests, bringing reactive UI programming techniques to Cocoa, would be much more interesting. Making native apps just as easy and as fun to build as web apps would be great! ReactiveCocoa/ReactiveSwift are promising, but the underlying, mutation-heavy Apple APIs still peek through. SwiftUI also seems promising, but still relatively immature to the, gosh, decades-old OS X platform.


Nothing really, pretty much the same as WIN32 api. May be added event bus is somehow faster than simple few-line-invent-at-home implementation.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: