robotlegs / robotlegs-framework

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

Remapping ViewProcessorMapper.toProcess() no throw errors? #150

Closed rayyee closed 11 years ago

rayyee commented 11 years ago

I mapMatcher and toProcess twice. then my processor execute twice. why not throw error? I found ViewProcessorMapper.toProcess(processClassOrInstance:*), if processClassOrInstance is instance, the _mappings maped 2 instance.

code:

viewProcessorMapper.mapMatcher( new TypeMatcher().anyOf( IAssetsInjection ) ).toProcess( InitializeViewProcessor ); viewProcessorMapper.mapMatcher( new TypeMatcher().anyOf( IAssetsInjection ) ).toProcess( InitializeViewProcessor );

then

InitializeViewProcessor.process... InitializeViewProcessor.process...

I need help! Thx.

creynders commented 11 years ago

Did you install the VigilanceExtension? Because then it should throw an error. It is automatically included in the MVCSBundle

rayyee commented 11 years ago

Thx creynders, I install the MVCSBundle. Because the 'processClassOrInstance' is instance, so the key is different. Don`t execute overwriteMapping

const mapping:IViewProcessorMapping = _mappings[processClassOrInstance];
            return mapping
                ? overwriteMapping(mapping, processClassOrInstance)
                : createMapping(processClassOrInstance);

I think if you want to avoid this problem, can map getQualifiedClassName(processClassOrInstance). But I do not know will not cause other problems?

creynders commented 11 years ago

Could you post your own code? I find it a bit confusing, since this:

viewProcessorMapper.mapMatcher( new TypeMatcher().anyOf( IAssetsInjection ) ).toProcess( InitializeViewProcessor );
viewProcessorMapper.mapMatcher( new TypeMatcher().anyOf( IAssetsInjection ) ).toProcess( InitializeViewProcessor );

definitely throws an overwrite mapping error. But apparently you want to map the same matchers to two different processor instances? Or?

rayyee commented 11 years ago

Because I accidentally wrote.

Sorry, the error code is:

viewProcessorMapper.mapMatcher( new TypeMatcher().anyOf( IAssetsInjection ) ).toProcess( new InitializeViewProcessor );
viewProcessorMapper.mapMatcher( new TypeMatcher().anyOf( IAssetsInjection ) ).toProcess( new InitializeViewProcessor );

And because I want to prevent the wrong result map of two instance, so I hope to throw error.

darscan commented 11 years ago

Hi. We can't throw an error based on getQualifiedClassName as it is perfectly valid to map two processors of the same class. For example, the instances may take configuration:

map...toProcess(new SomeProcessor(5));
map...toProcess(new SomeProcessor(6));
rayyee commented 11 years ago

Thx, darscan.

new SomeProcessor(5);
new SomeProcessor(6);

Yes, I can pass parameters to distinguish between two processor. But I think the developers need to pay attention to this situation.

Thanks very much.