Git Product home page Git Product logo

Comments (10)

knalli avatar knalli commented on June 29, 2024
  1. What about a chain/list of handlers?
  2. What about a similar list of handlers for success? Currently, this is a $rootScope broadcast.

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on June 29, 2024

For example?

from angular-translate.

knalli avatar knalli commented on June 29, 2024

Example for what? :)

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on June 29, 2024

It'd be great to get more details on what you've posted.

from angular-translate.

knalli avatar knalli commented on June 29, 2024

Just brainstorming.

1. Instead of one single failure handler, it could be list of handlers.
Reason 1: Currently we cannot use our own failure handler (apart from simple $log) because of same reasons like success (see down). Reason 2: Currently different independent handlers must be implemented in one single.

We can add another api or just extend this one to be optional adding (default replace just like before)

  this.missingTranslationHandler = function (functionHandler, noReplace) {
    if (angular.isUndefined(noReplace) || !noReplace) {
      if (angular.isUndefined(functionHandler)) {
        return $missingTranslationHandlers[0];
      }
      $missingTranslationHandlers = [functionHandler];
    } else {
      if (!angular.isUndefined(functionHandler) && functionHandler === true) {
        return $missingTranslationHandlers;
      } else {
        $missingTranslationHandlers.push(functionHandler);
      }
    }

// supporting
function fn() {}
equals([], missingTranslationHandler(true));
equals(undefined, missingTranslationHandler());
missingTranslationHandler(fn);
equals(fn, missingTranslationHandler());
equals([fn], missingTranslationHandler(true));
missingTranslationHandler(fn, true);
equals(fn, missingTranslationHandler());
equals([fn, fn], missingTranslationHandler(true));

* 2. Just like missingTranslationHandler, but for success.*

Before:

    $rootScope.$broadcast('translationChangeSuccess');

After:

    $successTranslationChangeHandler();

(Ore even a list because we will actually relay on that broadcast).

from angular-translate.

knalli avatar knalli commented on June 29, 2024

@PascalPrecht Gotcha. Renaming a project while commenting isn't supported by Github. No redirect, only an error ;)

from angular-translate.

knalli avatar knalli commented on June 29, 2024

Oh no wait.. the mail link is broken.

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on June 29, 2024

This is of course a pretty cool approach of handling several handlers for errors and success, but I'm not sure if this is currently really required.

If you want to, you can go ahead and implement this in canary. Otherwise, I'd just implement something like useMissingTranslationHandle('serviceString') or so, since this is currently totally enough.

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on June 29, 2024

Implemented this in f6ed3e3

Will merge it into master later today. Last chance to review!

from angular-translate.

0x-r4bbit avatar 0x-r4bbit commented on June 29, 2024

Landed in master.

from angular-translate.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.