Add js.Batch

Fixes #12626
Closes #7499
Closes #9978
Closes #12879
Closes #13113
Fixes #13116
This commit is contained in:
Bjørn Erik Pedersen
2024-12-10 16:22:08 +01:00
parent 157d86414d
commit e293e7ca6d
61 changed files with 4520 additions and 1003 deletions

View File

@@ -82,9 +82,8 @@ func FirstIdentity(v any) Identity {
var result Identity = Anonymous
WalkIdentitiesShallow(v, func(level int, id Identity) bool {
result = id
return true
return result != Anonymous
})
return result
}
@@ -146,6 +145,7 @@ func (d DependencyManagerProviderFunc) GetDependencyManager() Manager {
// DependencyManagerScopedProvider provides a manager for dependencies with a given scope.
type DependencyManagerScopedProvider interface {
GetDependencyManagerForScope(scope int) Manager
GetDependencyManagerForScopesAll() []Manager
}
// ForEeachIdentityProvider provides a way iterate over identities.
@@ -308,11 +308,13 @@ type identityManager struct {
func (im *identityManager) AddIdentity(ids ...Identity) {
im.mu.Lock()
defer im.mu.Unlock()
for _, id := range ids {
if id == nil || id == Anonymous {
continue
}
if _, found := im.ids[id]; !found {
if im.onAddIdentity != nil {
im.onAddIdentity(id)
@@ -320,7 +322,6 @@ func (im *identityManager) AddIdentity(ids ...Identity) {
im.ids[id] = true
}
}
im.mu.Unlock()
}
func (im *identityManager) AddIdentityForEach(ids ...ForEeachIdentityProvider) {
@@ -355,6 +356,10 @@ func (im *identityManager) GetDependencyManagerForScope(int) Manager {
return im
}
func (im *identityManager) GetDependencyManagerForScopesAll() []Manager {
return []Manager{im}
}
func (im *identityManager) String() string {
return fmt.Sprintf("IdentityManager(%s)", im.name)
}