robotlegs / robotlegs-framework

An ActionScript 3 application framework for Flash and Flex
https://robotlegs.tenderapp.com/
MIT License
967 stars 261 forks source link

Request for "group" of mappings. #162

Open ivan-shaban opened 10 years ago

ivan-shaban commented 10 years ago

Hi, can you implement "group" of mappings. E.g. you can make mapping with some token, and after remove all mappings according this token.

In my mind, that would require implementing a special mapping mechanism, where you could build a "group" of mappings, so that you could refer to that group when you want to unmap all the classes inside of it. Since the mappings are performed by different "mappers" (commandMap, mediatorMap, Injector itself), each of them should have an additional method for storing the mappings in a dictionary of groups.

injector.map(SomeModel).asSingleton().toGroup("someGroup");

mediatorMap.map(SomeView).toMediator(SomeMediator).toGroup("someGroup"); mediatorMap.map(AnotherView).toMediator(AnotherMediator).toGroup("anotherGroup");

commandMap.map(SomeEvent.SOME_TYPE, SomeEvent).toCommand(SomeCommand).toGroup("someGroup");

toGroup is of course a silly name:)

Then when you want to unmap them, calling

unmapFromGroup("someGroup");

would result in each "mapper" iterating through its own mappings-dictionary in order to unmap the classes belonging to "someGroup".

Detail discussion could be found here : http://knowledge.robotlegs.org/discussions/robotlegs-2/10174-is-there-any-way-to-easy-destroy-config