User tests: Successful: Unsuccessful:
Adding detach function for observers
in Class extends JTable
use
$this->_observers->detachObserver('specObserver');
Adds ability to detach observers
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Category | ⇒ | Libraries |
What's your use case for this. I'm hugely nervous of extensions disabling other extensions...
Status | Pending | ⇒ | Information Required |
Background
For example I have an object that can have one role or another:
User can be client, team member or team leader.
Role functionality implemented by observer because we know which role user have only depending on data that were loaded to user object.
We don't want to pull everything once again from data base and create new object, we can attach observer that corresponds to user role.
It's all working great.
Problem
But if team member becoming leader we need to apply leader observer instead of member. So detaching observer would be nice.
Also I don't quite understand your vision on this, as I attach observer to JTableExtender instance and how can I access same instance from other extension? JTable::getInstance always returns new Class()
@ggppdk
Sorry, but what you mean by this?
Can you provide working example which would not be hack for making something that should be essential?
I'll write a bit mess, but I believe everybody will get the point:
JTable{
public function attachObserver(JObserverInterface $observer)
{
$this->_observers->attachObserver($observer);
}
}
TUser Object
(
[_tbl:protected] => #__users
[_observers:protected] => JObserverUpdater Object
(
[observers:protected] => Array
(
[UserObserver] => UserObserver Object
(
[table:protected] => TUser Object
*RECURSION*
)
[TUserObserverCoordinator] => TUserObserverCoordinator Object
(
[table:protected] => TUser Object
*RECURSION*
)
)
[doCallObservers:protected] => 1
)
)
So as you can see from all the above:
I can access $this->_observers
But I can't access $this->_observers->observers
and iterate and unset as this is protected
About accepting this feature, it is not my call,
what you need to do for this to be considered, is :
and usually "new feature" PRs wait for much longer time that "bug-fixes" PRs, i hope you are not disappointed with it, if you make a few 'new feature' PRs, eventually one of them will be accepted
again this is not my call
Just to reference my points once again:
@ggppdk , well I know and understand that it's not your call. I'm just don't letting you to impose fear and doubts on call-makers.
I'm just don't letting you to impose fear and doubts on call-makers.
you over-estimate my effects , anyway i understand
I believe if any one says that something like
It's not compatible
or
Well, is it needed?
it is a ring call for rechecking and doubting changes. And I also think that it's right position in terms of repo maintaining as millions are using this code and
with great power come great responsibility
So some explanation like why this way and not another and why it's safe is good thing.
Ok I think the use case is fine. Does this patch work tho? Just on code review (as on holiday) isn't the key the class name rather than the observer itself?
Yes - but i'm holding on merging things until we're satisfied with 3.6.0 and are sure we don't need to make any quick follow up releases
Labels |
Added:
?
|
Labels |
Removed:
?
|
3.6.0 is out, Still waiting )
Status | Information Required | ⇒ | Pending |
Status | Pending | ⇒ | Ready to Commit |
RTC
Labels |
Added:
?
|
Milestone |
Added: |
Status | Ready to Commit | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-10-29 09:30:25 |
Closed_By | ⇒ | rdeutz |
thanks
Labels |
Removed:
?
|
@alex7r Please see alex7r#3