Skip to content
This repository has been archived by the owner on Mar 2, 2018. It is now read-only.

SimpleObserver test not present #1

Open
etcimon opened this issue Jan 24, 2014 · 5 comments
Open

SimpleObserver test not present #1

etcimon opened this issue Jan 24, 2014 · 5 comments

Comments

@etcimon
Copy link

etcimon commented Jan 24, 2014

I can't see any tests for SimpleObserver in stdx.signals, it's not fully obvious that omitting some function parameters would be acceptable for a valid observable.

On a side note, I'm wondering if the mixins could be replaced by something more simple. I intend on using this signals library for the web development framework I'm developing. Without seeing this library, I had a vision of something like

class MyLib {
    Event!("onLibStarted", bool, string) m_hook;

    this(){
        if (!m_hook.call("started")) return;
        ...
    }

}

Where Event would be a template like this:

template Event(string Name, OUT, IN...) { }

Being able to request info while emitting is something I really need, because some routines could be skipped/aborted/modified by some other libraries compiled against other libraries (completely different programs). For example, it could allow writing plugins that attach to hooks and add data to the routines there..

But, sending some arguments as ref would also do.

@PaulFreund
Copy link
Collaborator

The signal module is taken from the phobos review queue and was proposed to replace std.signal in phobos (it was rejected in the first voting). The code is not modified and the best place to discuss it is probably the review thread. As alternatives I can suggest the eventing framework in vibe.d, a (imperfect) solution I wrote - pubsub.d or the solution I currently work on - nitro (unfortunately lacks documentation at the moment).

@etcimon
Copy link
Author

etcimon commented Jan 24, 2014

For what I need, your pubsub would be just perfect, I only need to adapt the publish and callSubscribers to move structs or other lvalues by reference. Nitro seems like it has its own event loop? and I already had something in mind for extension handling to install components. They need to be registered in vibe.d routers pre-runtime which makes it more complicated

@PaulFreund
Copy link
Collaborator

I'd gladly accept a pull request like that. pubsub.d is not very efficient at the moment and I stopped using it for my current project but that would be the the next important step.
Nitro can be used in different ways, in a few days (I hope) I'll be done with the basics and write a documentation.

@etcimon
Copy link
Author

etcimon commented Jan 24, 2014

I'm looking at https://github.com/Orvid/std.event for the moment, it looks like pub/sub with return types but without wildcards. Could that be the only difference?

@Zoadian
Copy link
Owner

Zoadian commented Jan 24, 2014

https://github.com/Orvid/std.event seems to be a wrapper for for a delegate array.
problem is that it will keep strong references to your event handlers.
stdx.signals implements weak references (and strong ones : strongConnect)

nitro can be used with a cusom run loop: just don't use nitro.gen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants