Comments (3)
I too dislike the implementation. So I asked myself, how would I want to use this.
Essentially, I would like to create a package that contained library that when imported, would do the right thing depending on my environment.
So, how about this.
main.dart
import library.dart;
// F3 Open Declaration => "interface.dart"
// F? Open Implementations => "server.dart" | "browser.dart"
var foo = new Foo();
library.dart
import basic.dart;
interface class Foo {
Foo();
}
basic.s.dart
env server;
import "dart:io";
import "interface.dart";
implementation class Foo {
File _file;
Foo() {
file = new File();
}
}
basic.w.dart
env web;
import "dart:html";
import "interface.dart";
implementation class Foo {
Element _element;
Foo() {
_element = new DivElement();
}
}
The expected behavior would be, I'm in a browser, I will use the library portion that states it is for the web. We could even use the part functionality.
But this should hide the complexity from the user of the library, since s/he shouldn't need to deal with it at all. Remember, we want to keep Dart the clean language it is, not add verbosity that is implied.
from dep-configured-imports.
I think an interface library can be supported via a pattern like:
library foo;
import (conditionally src/server.dart or src/browser.dart which both contain a FooImpl);
class Foo {
const Foo() = FooImpl;
}
from dep-configured-imports.
This approach assumes a fixed number of environments, and doesn't expand to user defined configurations.
It also requires loading a library to check whether it matches the current environment, which isn't desirable.
from dep-configured-imports.
Related Issues (11)
- Slightly confusing example in syntax HOT 1
- Support implementing cross-platform interfaces HOT 17
- Less punctuation? HOT 27
- clarify interaction with analyzer HOT 9
- Allow use conditional directives at least within the section of the import/export directives HOT 5
- dart.feature.html to match `dart:html` HOT 1
- Do we need platform sniffing if we have feature detection? HOT 5
- Are we sure we want the library choose? HOT 7
- Configure imports based on Platform and Architecture HOT 1
- extending expression language to handle package versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dep-configured-imports.