Giter VIP home page Giter VIP logo

Comments (5)

pulyaevskiy avatar pulyaevskiy commented on September 28, 2024 1

Here is portion of official Dart style guide re: naming constants and enum values:
https://www.dartlang.org/guides/language/effective-dart/style#prefer-using-lowercamelcase-for-constant-names :

In new code, use lowerCamelCase for constant variables, including enum values.

I'd prefer to stick to the style guide as it makes this Dart code consistent with most of the Dart code available on Pub and the Dart SDK itself.

from firebase-admin-interop.

pulyaevskiy avatar pulyaevskiy commented on September 28, 2024

I think enum fits well in this case. Only thing is that we should name values without underscores to comply with Dart style guide, e.g. EventType.childAdded.

Note that it would be a breaking change so would have to be released as 2.0.0 which for such a small change might be hard to justify major version bump.

We can approach this in two steps:

  1. Add assertions as per your second suggestions, this would be non breaking. We can also add an abstract class with constants so that users are not forced to hard code strings. E.g.:
abstract class EventType {
  static const String childAdded = 'child_added';
  // ... etc
}

Would be nice to update examples and dartdocs to refer to these constants so that it's easier to discover.

All of this is non-breaking and we can release it in 1.x.x.

  1. When we gather enough breaking changes or there is upstream (JS SDK) change that requires us to bump major version to 2.0.0 we can replace the abstract class with an enum and update all method signatures accordingly.

How does this sound?

from firebase-admin-interop.

m1-nann avatar m1-nann commented on September 28, 2024

naming: if we are not using the firebase string name child_added, I suggest considering uppercase low dash (ie. CHILD_ADDED). Maybe it's just a personal preference, though it's also used for firebase.database.ServerValues.TIMESTAMP.

I understand the possible breaking changes, so the two steps are pretty good ideas.

from firebase-admin-interop.

m1-nann avatar m1-nann commented on September 28, 2024

Oh, I see. I was searching for 'constant' and 'enum' but didn't catch it somehow. My bad.

from firebase-admin-interop.

pulyaevskiy avatar pulyaevskiy commented on September 28, 2024

FYI: I added EventType with constants as per discussion and released together with your change of the on method as 1.2.0.

from firebase-admin-interop.

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.