Singleton in MVP GWT project
I'm wondering should i use Singleton for my presenters? What is the benefit of it?
I have a weird behavior in my simple project, i have a form which is used to add new records in db and display in a table, so after the first add "click" it works ok, but in the next second or third "click" 开发者_Go百科then it comes weird. For example on the second click the event is called twice and the input is inserted twice in db, if you do third click the input will be inserted three time in db, why this happen?
Thanks
Edit So far my presenters and views are Singleton , also EventBus and PlaceManager.
Implementing presenters as a singletons can reduce testability of your code.
Consider using a Dependency Injection. Gin works perfectly with GWT apps.
totaly difficult to answer that without seeing the code, maybe you can post the methods which are called after pressing the button?
精彩评论