Search code examples
user-interfacedvibed

Possible use case of Graphical user interface integration using Vibe.d


One selling point of Vibe.d is its Support for graphical user interfaces.

So far, I can't fancy a decent use case leveraging this feature and would be very pleased if someone can tell more about it.

Anything related to (Twitter) Stream API for instance?!


Update:

I'm just asking for one example to get started and limit the scope of this post.


Solution

  • Here's what the documentation says: http://vibed.org/features#productivity


    Graphical user interface integration

    Contrary to most other frameworks supporting asynchronous I/O, vibe.d fully integrates with the UI event loop, so that it can be used to power applications with a graphical user interface.

    For Windows, there is a native event driver implementation (enable with VibeWin32Driver) that makes use of the MsgWaitForMultipleObjectsEx function to process window messages together with I/O or concurrency events. For systems running X11, it's possible to use createFileDescriptorEvent to listen on the display connection instead of using XNextEvent.


    I haven't used vibe.d so I'm not really authorative on this, but I have written similar code before so that description tells me my experience surely applies.

    When you are writing a GUI program, one of the difficulties can be remaining responsive to user inputs (window events) while using custom events too - many frameworks do their own event loop to respond to data-ready messages and the GUI application needs an event loop too to respond to stuff like mouse-clicked messages.

    vibe.d can use one event loop for both, just meaning you can use its async I/O features while handling window messages without needing a separate GUI thread and without blocking on a message mucking up I/O.

    I guess a concrete example might be a server application with a control+stats window visible for the administrator.

    The case I looked into similar code for was handling console input, GUI input, and network input writing a network enabled terminal emulator. I had to handle incoming ssh packets, key presses, and abort input from the parent terminal all without blocking.