Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DotLabelable mechanism doesn't suit enum cases with associated values #36

Open
aufflick opened this issue Feb 8, 2017 · 1 comment
Open

Comments

@aufflick
Copy link

aufflick commented Feb 8, 2017

The whole DotLabelable mechanism could do with a rethink - for example if your state enum cases have associated values (which mine do, and is an awesomely powerful feature of this approach) then you can't easily create the DotLabelable array (unless your associated values are something simple like strings).

@narfdotpl
Copy link
Contributor

Hi,

I understand it can be annoying but I don't see it as a big problem: you just have to provide a value of the type you declare. I'm happy to discuss other approaches but nothing else comes to my mind given the fact that the list of items used to generate the diagram has to be passed to the actual transition logic code in order for the diagram to be always up to date.

Here's an example from my project:

enum Dynamic {
    case Normal
    case Gentle
}


enum Strength {
    case Normal
    case Strong
    case VeryStrong
}


enum SquareNodeEvent: DOTLabelable {
    case Highlight(delay: Double, dynamic: Dynamic, strength: Strength)
    // ...

    static let DOTLabelableItems = [
        Highlight(delay: 0, dynamic: .Normal, strength: .Normal),
        // ...
    ]

    var DOTLabel: String {
        switch self {
            case .Highlight: return "Highlight(delay, dynamic, strength)"
            default:         return "\(self)"
        }
    }
}

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

No branches or pull requests

2 participants